refactoring minister form javascript