checks for valid input