random number bug fixes