Refactor ScopePlugin