added methds for isLastSegment