clean up error reporting
clean up error reporting, refactor form submission logic