optimize form validation