updated input validation