added error checking to input rather than exiting on bad input