Fixed the random function