updating random function