If I may ask: Could you describe your plan for doing this in words, i.e. how do you deal with the sequence steps? From the code, I cannot really tell, I would have expected a for loop over the sequence index.