improved form validation