diff --git a/AstBuilding.py b/AstBuilding.py
index 032b03e8871e4925c835c5faf0cd0c48be9d03ab..22e7acdfb2ef166b9e18785281f6f47e344aa1c9 100644
--- a/AstBuilding.py
+++ b/AstBuilding.py
@@ -24,6 +24,7 @@ def buildEnvAndLink(ASTs):
         try:
             t[1].recurseBuildEnv(globalEnv)
         except Exception as e: # to handle double local variable declaration
+            raise e
         print('\n\n\n', t[0])
         print("###################### Comp Unit Env ####################")
         t[1].recurseAction("printEnv")
diff --git a/joosc.py b/joosc.py
index 651d2cebd9814959e018fe64fc8f661d804f66ca..4e4ad390089f574d230ca401413ca9fc2eb31e3b 100644
--- a/joosc.py
+++ b/joosc.py
@@ -5,37 +5,54 @@ from os.path import isfile, join
 
 from Scanning import scan
 from Parsing import parse
-from Weeding import weedTokens
+from AstBuilding import astBuild, buildEnvAndLink
+import Weeding
 
 
 def main():
-    inputfile = sys.argv[1]
-    content = open(inputfile, "r").read()
-
-    # Scanning
+    inputFiles = [f for f in sys.argv[1:]]
+
+    parseTrees = []
+
+    for f in inputFiles:
+        content = open(f, "r").read()
+
+        # Scanning
+        try:
+            (tokens, error) = scan(content)
+        except:
+            return 42
+        if tokens is None:
+            return 42
+
+        # Weeding after scanning
+        # No weeds if everything is good (weeds = None)
+        weeds = Weeding.fileNameCheck(tokens, f)
+        if weeds:
+            return 42
+
+        # Parsing
+        tree = None
+        try:
+            (tree, error) = parse(tokens)
+        except:
+            return 42
+
+        # Error in Parsing
+        if tree is None:
+            return 42
+
+        parseTrees.append((f, tree))
+        print(tree)
+
+    # Building ASTs from all parse trees
+    ASTs = astBuild(parseTrees)
+    
     try:
-        (tokens, errorString) = scan(content)
-    except:
-        return 42
-
-    # Error in Scanning
-    if tokens is None:
-        return 42
-
-    # Weed the tokens
-    weeds = weedTokens(tokens, inputfile)
-    if weeds != "":
-        return 42
-
-    # Parsing
-    (steps, error) = parse(tokens)
-
-
-
-    if steps is None:
-        return 42
+        buildEnvAndLink(ASTs)
+    except Exception as e:
+        return 42 # double local variable declarations
 
-    # print("success in scanning and parsing")
     return 0
 
 re = main()