fix bug in querySegmentWithCoords