added isValid to check if the form is valid