add reduce to prevent overflow
add intersection of segments