Implemented getBestMatchingSegment