Fix randomization bug