updated form processing logic