added segment tree implementation