Deduplicate logic