Refactor dialog