update the random function