updated random number generation