working SegmentTree