refactor line segment intersection into 2 functions