adding onInvalid callback