fixed dumb errors, check fo line segment ends