input validation logic