fixed random function