added error checking to windows random