refactor scope