fix tree index check