Adding duplicate detection