implemented form validation