fix error in the intersection function