Improved form validation