Updated formhandler with debugging