move and clarify code for randomization