Updated random number generator code