random number generator now works correctly