create btree instead of array to be computed
clean code