fix lint errors
refactor to find the closest segment to click, and split at the intersection point