Changed random function