Made collapseDuplicates