Added duplicate detection to core data implementation