Made one function in generating random numbers