Blocks not randomized in pavlovia

For my second Q:
I want to randomize the order of Blocks as indicated in the image. Sometimes B1 will come, sometimes B2. However, creating several inner and outer loops ended up problematic data output. That is why I wanted to randomize the blocks with a code. So, ret1 and ret2 do not matter they are just for randomizing the order of routines.

In this suggestion, I did not understand how you defined n_b1_first cause in my Control loop, the nReps are defined as nRepsIm (for block1) and nREpsLan (for block2)