added user input validation