Added duplicate detection