Fixed random number handling