Better RNG algorithm