random function fix