Fix form url bug and refactoring