added a function to make input validation