Refactor scopes