added calculation of intersections.