improved tool input validation