Created new function to check for valid user input.