#51 refactor replace and showing dialogs