Refactor of surfce_intersections function.