fix a bug on generate random number.