Completed compressDuplicates