implement intersect function with binary search