refactored planning js file for better maintainability closes #20