Random number generator bug fix