Refactor dialog boxes