Fix random number generation