random number generator improved and tested