Improved the random number generator