refactor save into btree class