Refactor for DUPSORT iteration.