added duplicate check for union and intersect