Bug fix on segtree