Fix random function.