improve input validation