fix deduping logic