modify the random function in ex-3.5