merge/detect duplicates