diff --git a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag
index 8a8ef7fa514a592b83d1242062aac46d58463aca..b7af23bbd86947137cbf626d5eff22676ee9e0a3 100644
--- a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag
+++ b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag
@@ -1,23 +1,8 @@
 aspect ProgramToScopeTree {
-  syn lazy ScopeTree Program.scopeTree() {
-    ScopeTree tree = new ScopeTree();
-    tree.setProgram(this);
-
-    for (CompilationUnit compilationUnit : getCompilationUnitList())
-      for (TypeDecl typeDecl : compilationUnit.getTypeDeclList()) {
-        if (typeDecl.isClassDecl()) {
-          // do not add the TypeDecl, if it has a superclass from source
-          ClassDecl classDecl = (ClassDecl)typeDecl;
-          if (!classDecl.superclass().compilationUnit().fromSource()) {
-            tree.addElement(((ClassDecl)typeDecl).publicScope());
-          }
-        } else {
-          tree.addElement(typeDecl.scope());
-        }
-      }
+  coll ScopeTree Program.scopeTree() [asScopeTree()] with addElement root Program;
 
-    return tree;
-  }
+  TypeDecl contributes scope() when !isClassDecl() to Program.scopeTree();
+  ClassDecl contributes publicScope() when !isInnerType() && !superclass().compilationUnit().fromSource() to Program.scopeTree();
 
   /** a relational nta collection attribute to compute the scope tree */
   coll Scope ASTNode.scope() [asScope()] with addElement root Program;
@@ -50,7 +35,6 @@ aspect ProgramToScopeTree {
   syn lazy ScopeTree Program.asScopeTree() {
     ScopeTree tree = new ScopeTree();
     tree.setProgram(this);
-
     return tree;
   }