fixed division error for randomization