fix random number function