Set up function to validate user input