small optimization in random number generation