add duplicate detection