Replacing the linear search in modifyNamedScope.