added validation before submitting form