added comments to explain the error handling of user input