Loop-free randomization algorigthm