refactor dialog