fixed bugs, extract segtrees