Creating Parent Records in Microflow

Hi I have a microflow that calls a form, collect some data including multiple serial numbers. I then want to loop through the serial number and create a an equipment records for each serial number. At the same time I want to create a new storage bin every 10 serial numbers. Everything works, except for creating the storage bin. The domain model is simple as it is the Storage Bin as the parent and the Equipment as the child. When inside the loop, I can’t find a good way to create a new Storage Bin every 10 times. I keep getting an out-of-scope error. Here is what the loop looks like. I can see how the error message occurs as there is a path through the loop that does not create a Storage Bin. What I am struggling with is how to rewrite the loop to create the Storage every 10 times and have attach to the Equipment object.   Thanks
1 answers

Just a quick advise, please continue if you can. Note that, commit in loop is not recommended, you need to find out the way to commit from out of a loop. A hint is create a list out of the loop then use inside the loop, then commit outside the loop. Your homework ^^