tree logic fix