DMG Algorithm