added error checking for user input