fixed isInputValid()