How to stop conditions from being repeated in a nested loop

This thread may have some helpful suggestions: Randomisation between and within loops without repetition