refactor form creation js