tried fixing the random number generation