Enhanced random number generation and tested it