New function for deduping