added code to check user input