Fixed Btree loop