added the random number formula to the for loop