fixed wrong tree building