fixed random function to actually be random