fixed bugs in drawing and searching for line segment