added error checking to ensure proper input from user