refactoring the organize.js and processdialog code