implement input validation