Refactor form controller