added exception handling for user input