dnd refactor