adjust random function