Adding logic to validate the user input