Simplified duplicate detection routine