added error checking to initRandom()