refactor page form handling