refactoring processdialog code