Fixed bug in user input and error checking