bugs fixed, better rng