Fixed duplicate detection