improved the randomness generation