fixed bad randomness and replaced shuffle with plain random.