Added validation check for user input