fix random number generation