refactor for extension use