adding improved form handling