updated form handler for errors