rearranged for tree