Pattern not working within repeat block

I created this code to produce an AABBCC pattern. http://www.tynker.com/play/5cb7a522cebfbd568a0bdfce-223475XlZdDnRdnHKV.ro8ha8QV5Qk
If I run the code using iteration - the pattern is out-of-whack.
If I take the code out of the repeat block, and run it, it produces the result I’m looking for.
I can’t see why - I wouldn’t mind some advice.

Paul

It’s the number of iterations - overriding some of the initial blocks.

one of the solution might be:

please note there is a red button and a green button
red: clear
green: run the pattern

on top of the problem that you noted there are some issues with share and embedded programs where actors are duplicated and code is not saved correctly. (when you run the code I have sent you can see and additional button but if you remix the code you can see that the extra button disappear.
Thx Zohar