try putting isValid function