improve dialogs code