added a helper method to check user input