improve btree code