Changed collapseDuplicates to a static method
Changed collapseDuplicates to a static method