check if input is valid