improving error checking on form submissions