added support for breaking line segment
rearranged a bit