diff --git a/comsdk/__pycache__/edge.cpython-37.pyc b/comsdk/__pycache__/edge.cpython-37.pyc
index a6588616675961196f9fd99211bb67c003ce1e4b..bd2dc548af1af5286cfdca6ff4b43f3b0eef25df 100644
Binary files a/comsdk/__pycache__/edge.cpython-37.pyc and b/comsdk/__pycache__/edge.cpython-37.pyc differ
diff --git a/comsdk/__pycache__/graph.cpython-37.pyc b/comsdk/__pycache__/graph.cpython-37.pyc
index 03877b0678b87e637ef1c969ff2fb57e7b8cffec..0ebe4d354559df8f3ada498981e822a550b63bcf 100644
Binary files a/comsdk/__pycache__/graph.cpython-37.pyc and b/comsdk/__pycache__/graph.cpython-37.pyc differ
diff --git a/comsdk/__pycache__/parser.cpython-37.pyc b/comsdk/__pycache__/parser.cpython-37.pyc
index f53f59824708bbf4de4bbc2a497a9ad91e5d734c..adfbfa8ff04bc5dc3759cd1764dd382d1a107347 100644
Binary files a/comsdk/__pycache__/parser.cpython-37.pyc and b/comsdk/__pycache__/parser.cpython-37.pyc differ
diff --git a/comsdk/edge.py b/comsdk/edge.py
index 9e803246ab6ebd56300f3c752ce1bf3e2d1f5471..2638325c30481d970a4db5fd963e2f0e34ec1248 100644
--- a/comsdk/edge.py
+++ b/comsdk/edge.py
@@ -60,10 +60,19 @@ class Edge(object):
     def morph(self, data, dynamic_keys_mapping={}):
         # print(self.pred_name, self.morph_name, self.order)
         proxy_data = self._io_mapping.build_proxy_data(data, dynamic_keys_mapping)
-        #print(proxy_data)
+        # print(proxy_data)
         self.preprocess(data)
         self._morphism(proxy_data)
         self.postprocess(data)
+    
+    def __str__(self):
+        out = ""
+        if not (self.pred_module =="" or self.pred_name ==""):
+            out += "{}::{}(data);\n".format(self.pred_module, self.pred_name)
+        if not (self.morph_module =="" or self.morph_name ==""):
+            out += "{}::{}(data);\n".format(self.morph_module, self.morph_name)
+        return out
+    
 
 # class DummyEdge(Edge):
     # def __init__(self):
diff --git a/comsdk/graph.py b/comsdk/graph.py
index b63e087db197b8859dcefe6aa9478a87355031e5..7aa249281ac5429730af6156b871f662fc0bfab1 100644
--- a/comsdk/graph.py
+++ b/comsdk/graph.py
@@ -116,7 +116,15 @@ class Graph:
             data['__WORKING_DIR__'] = data['__CURRENT_WORKING_DIR__']
     
     def generate_cpp(self):
-        pass
+        cur_state = self.init_state
+        while True:
+            if len(cur_state.transfers)==1:
+                print(cur_state.transfers[0].edge)
+                cur_state = cur_state.transfers[0].output_state
+                if cur_state is None:
+                    break
+            else:
+                break
 
 
 
@@ -170,13 +178,9 @@ class State:
                 return # no need to go further if we already were there
             if self._branching_states_history is None:
                 self._branching_states_history = branching_states_history
-            print(self.name,": \t", self.input_edges_number, len(self.transfers))
-            print(self._branching_states_history)
         elif idle_run_type == IdleRunType.CLEANUP:
             self.activated_input_edges_number = 0
-#           print('\tCLEANUP STATE {}, active: {}, branches_story: {}'.format(self.name, self.activated_input_edges_number, self._branching_states_history))
             if self._branching_states_history is not None and self._is_looped_branch(branching_states_history):
-#                print('\tqwer')
                 self._branching_states_history = None
                 return
             if self._branching_states_history is None:
@@ -280,12 +284,6 @@ class State:
     def _has_loop(self):
         return self.looped_edges_number != 0
 
-    def generate_cpp(self):
-        ststr = "{}:\n\t".format(self.name)
-        if len(self.transfers)==1:
-            print("{}(data);\n{}(data);".format(t.edge.pred_name, t.edge.morph.name))
-            return
-
 
 def transfer_to_termination(data):
     return None
diff --git a/comsdk/parser.py b/comsdk/parser.py
index 92c604e1442746a79a30194596434bd8d1b6807c..083b7d90855388abaf156ce54c74521ac8e4b85f 100644
--- a/comsdk/parser.py
+++ b/comsdk/parser.py
@@ -85,12 +85,12 @@ class GraphFactory():
         self.states[st1].connect_to(self.states[st2], edge=Edge(pred, entr, order=ordr))
         print("{} -> {}".format(st1, st2))
 
-    def build(self):
+    def build(self, nsub):
         print("BUILDING {}\nStates:".format(self.name))
         for s in self.states:
             print("\t"+ s)
         if self.issub:
-            self.graph = Graph(self.states[self.name+"_"+"__BEGIN__"], self.states[self.name+"_"+"__END__"])
+            self.graph = Graph(self.states[self.name+str(nsub)+"_"+"__BEGIN__"], self.states[self.name+str(nsub)+"_"+"__END__"])
         else:    
             self.graph = Graph(self.states["__BEGIN__"], self.states["__END__"])
         self.graph.init_graph()
@@ -108,7 +108,6 @@ class GraphFactory():
                 parsr = Parser(subgraph=True)
                 subgr = parsr.parse_file(self.entities[s].subgraph)
                 self.states[s].replace_with_graph(subgr)
-        self.graph.init_graph()
         return self.graph
 
 class Parser():
@@ -117,11 +116,13 @@ class Parser():
         'fact',
         'issub'
     )
-
+    subgr_count = 0
     def __init__(self, tocpp=False, subgraph=False):
         self.fact = GraphFactory(tocpp=tocpp)
         self.fact.issub = subgraph
         self.issub = subgraph
+        if subgraph:
+            Parser.subgr_count+=1
     
     def _check_brackets(self, rawfile):
         br = 0
@@ -185,8 +186,7 @@ class Parser():
             if r[0] in parm.__slots__:
                 setattr(parm, r[0], r[1])
             else:
-                print("\tERROR:Unknown parameter: "+ r[0])
-                exit(-1)
+                raise Exception("\tERROR:Unknown parameter: "+ r[0])
         return parm
 
     def _param_from_entln(self, raw):
@@ -207,9 +207,9 @@ class Parser():
         right = spl[2].split(",")
         if self.issub:
             for i in range(len(left)):
-                left[i] = self.fact.name + "_" + left[i]
+                left[i] = self.fact.name + str(Parser.subgr_count) + "_" + left[i]
             for i in range(len(right)):
-                right[i] = self.fact.name + "_" + right[i]
+                right[i] = self.fact.name + str(Parser.subgr_count) + "_" + right[i]
         if (len(left)>1) and (len(right)>1):
             raise Exception("ERROR: Ambigious multiple connection in line:\n\t{}".format(raw))
         # many to one conection
@@ -279,5 +279,5 @@ class Parser():
                 self.fact.entities[name] = parm
             elif top_re.match(ln):
                 self._topology(ln)
-        return self.fact.build()
+        return self.fact.build(Parser.subgr_count)
 
diff --git a/test_parser.py b/test_parser.py
index a2c9d13cbeb03f9ab790e530ad647e0f310c8ebf..38acc88db1b50b396916c2f13dc7568f4db337d0 100644
--- a/test_parser.py
+++ b/test_parser.py
@@ -9,22 +9,40 @@ from comsdk.graph import *
 from comsdk.edge import Edge
 
 prsr = pars.Parser()
-print(prsr.fact.tocpp)
-graph = prsr.parse_file('./tests/adot/testparal.adot')
-
-# s_1 = State('cycled_s_1')
-# s_2 = State('cycled_s_2')
-# s_3 = State('cycled_s_3')
-# s_1.connect_to(s_2, edge=Edge(Func(),Func(func=increment_a_edge)))
-# s_2.connect_to(s_3, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
-# s_2.connect_to(s_1, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
-# 
-# graph = Graph(s_1, s_2)
-
+graph = prsr.parse_file('./tests/adot/testsimple.adot')
 
 data = {"a":1, "b":1}
-# graph.generate_cpp()
 graph.run(data)
-
 print(data)
 
+
+print(graph.generate_cpp())
+
+# root = State('root')
+# br2 = State('br2')
+# br3 = State('br3')
+# br2_sibl1 = State('br3_sibl1')
+# br2_sibl2 = State('br3_sibl2')
+# br3_sibl1 = State('br3_sibl1')
+# br3_sibl2 = State('br3_sibl2')
+# end = State('end')
+# 
+# root.connect_to(br2, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# root.connect_to(br3, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br3.connect_to(br3_sibl1, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br3.connect_to(br3_sibl2, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br2.connect_to(br2_sibl1, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br2.connect_to(br2_sibl2, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br3_sibl1.connect_to(end, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br3_sibl2.connect_to(end, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br2_sibl1.connect_to(end, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# br2_sibl2.connect_to(end, edge=Edge(Func(func=positiveness_predicate), Func(func=increment_a_edge)))
+# 
+# graph = Graph(root, end)
+
+
+# data = {"a":1, "b":1}
+# graph.run(data)
+# 
+# print(data)
+
diff --git a/tests/__pycache__/test_graph.cpython-37.pyc b/tests/__pycache__/test_graph.cpython-37.pyc
index 30d21aa8aa0528f6953c3930ea854d31a4ff8c13..bd0ab9367936823833c779acfac2b3f9ead9e066 100644
Binary files a/tests/__pycache__/test_graph.cpython-37.pyc and b/tests/__pycache__/test_graph.cpython-37.pyc differ
diff --git a/tests/adot/simple.adot b/tests/adot/testcycl.adot
similarity index 87%
rename from tests/adot/simple.adot
rename to tests/adot/testcycl.adot
index 6f842ee1d79247925cd26fa1ee8388a9bb6ff19c..71d9bbcb62f9df4aff6b9c0c5013da101741b6fd 100644
--- a/tests/adot/simple.adot
+++ b/tests/adot/testcycl.adot
@@ -1,4 +1,4 @@
-digraph SIMPLEST {
+digraph CYCLED {
     FUNC [module=test_funcs.simplest, entry_func=decrement_a_edge]
     PRED [module=test_funcs.simplest, entry_func=positiveness_predicate]
     MORPH [predicate=PRED, function=FUNC]
@@ -9,6 +9,6 @@ digraph SIMPLEST {
     
     __BEGIN__ -> ST1 
     ST1 -> ST2 [morphism=MORPH]
-    ST2 -> ST1 
+    ST2 -> ST1 [morphism=MORPH]
     ST2 -> __END__
 }
\ No newline at end of file
diff --git a/tests/adot/testparal.adot b/tests/adot/testparal.adot
index d5637f92fc06e2544164fc3d6497576a603d866c..fea3782e076c3b1a70356f282a1c62bfc7b04455 100644
--- a/tests/adot/testparal.adot
+++ b/tests/adot/testparal.adot
@@ -6,11 +6,11 @@ digraph SIMPLEST {
     INCR_B [predicate=PRED, function=FUNCB]
     
 
-    __BEGIN__ -> ST2 
-    ST2 -> ST3_1, ST3_2 [morphism=(INCR_A, INCR_B)]
-    ST3_1 -> ST3_1_1, ST3_1_2 [morphism=(INCR_A, INCR_B)]
-    ST3_2 -> ST3_2_1, ST3_2_2 [morphism=(INCR_A, INCR_B)]
-    //ST3_1_1 -> ST3_1_1_1, ST3_1_1_2
-    ST3_1_1, ST3_1_2, ST3_2_1, ST3_2_2 ->  ST_TERM [morphism=(INCR_A, INCR_B, INCR_A, INCR_B)]
-    ST_TERM -> __END__
-}
\ No newline at end of file
+    __BEGIN__ -> ROOT
+    ROOT -> BR1, BR2, BR3 [morphism=(INCR_A, INCR_A, INCR_A)]
+    BR3 -> SIBL3_BR1, SIBL3_BR2 [morphism=(INCR_A, INCR_A)]
+    BR2 -> SIBL2_BR1, SIBL2_BR2 [morphism=(INCR_A, INCR_A)]
+    SIBL3_BR1 -> SIBL3_BR1_1,  SIBL3_BR1_2 [morphism=(INCR_A, INCR_A)]
+    SIBL3_BR1_1,  SIBL3_BR1_2 -> TERM  [morphism=(INCR_A, INCR_A)]
+    BR1,  SIBL2_BR1, SIBL2_BR2, TERM, SIBL3_BR2 ->  __END__ [morphism=(INCR_A, INCR_A, INCR_A, INCR_A, INCR_A)]
+} 
\ No newline at end of file
diff --git a/tests/adot/testsimple.adot b/tests/adot/testsimple.adot
new file mode 100644
index 0000000000000000000000000000000000000000..8c0e220e65b64635f165bed438cd6d31943fc3f6
--- /dev/null
+++ b/tests/adot/testsimple.adot
@@ -0,0 +1,10 @@
+digraph SIMPLE {
+    FUNC [module=test_funcs.simplest, entry_func=increment_a_edge]
+    PRED [module=test_funcs.simplest, entry_func=positiveness_predicate]
+    MORPH [predicate=PRED, function=FUNC]
+    __BEGIN__ ->  ST1 [morphism = MORPH]
+    ST1 -> ST2 [morphism = MORPH]
+    ST2 -> ST3[morphism = MORPH]
+    ST3 -> ST4[morphism = MORPH]
+    ST4 -> __END__
+}
\ No newline at end of file
diff --git a/tests/adot/testsub.adot b/tests/adot/testsub.adot
index ded8bb84adea058637e35efdb7d3e5460257f57f..a260fe942a201472c37e4c7af6e57b06b1edeec0 100644
--- a/tests/adot/testsub.adot
+++ b/tests/adot/testsub.adot
@@ -1,11 +1,11 @@
 digraph TEST_SUB {
-    FUNC [module=test_funcs.simplest, entry_func=decrement_a_edge]
+    FUNC [module=test_funcs.simplest, entry_func=increment_a_edge]
     PRED [module=test_funcs.simplest, entry_func=positiveness_predicate]
     MORPH [predicate=PRED, function=FUNC]
 
-    ST2 [subgraph = tests/adot/add.dot]
+    ST2 [subgraph = tests/adot/add.adot]
     
     __BEGIN__ -> ST1 
     ST1 -> ST2 [morphism=MORPH]
-    ST2 -> __END 
+    ST2 -> __END__
 }
\ No newline at end of file
diff --git a/tests/test_graph.py b/tests/test_graph.py
index cc16e338ba240518d05d2074bb2c757ffe916724..160e2348a891f64149e5c13fd9c381e432c2c209 100644
--- a/tests/test_graph.py
+++ b/tests/test_graph.py
@@ -230,24 +230,30 @@ class GraphGoodCheck(unittest.TestCase):
 
     def _get_trivial_parallel_graph(self, initial_conditions):
         '''
-        s_1 -> s_2 -> s_3 -> s_6
-            -> s_4 -> s_5 ->
+        s_1 -> s_2 -> s_3 ---------> s6s
+            -> s_4 -> s_4_1 -> s_5 
+                   -> s_4_2            
         p_12 = p_24 = p_13 = p_34 := a not 0
         f_12 = f_24 := a + 1
         f_13 = f_34 := b + 1
         '''
 
-        s_1 = State('nonparallel_s_1', selection_policy=AllSelectionPolicy())
+        s_1 = State('nonparallel_s_1')
         s_2 = State('parallel_s_2')
         s_3 = State('parallel_s_3')
         s_4 = State('parallel_s_4')
+        s_4_1 = State('parallel_s_4_1')
+        s_4_2 = State('parallel_s_4_2')
         s_5 = State('parallel_s_5')
         s_6 = State('nonparallel_s_6')
         s_1.connect_to(s_2, edge=Edge(nonzero_predicate, increment_a_edge))
         s_2.connect_to(s_3, edge=Edge(nonzero_predicate, increment_a_edge))
         s_3.connect_to(s_6, edge=Edge(nonzero_predicate, increment_a_edge))
         s_1.connect_to(s_4, edge=Edge(nonzero_predicate, increment_b_edge))
-        s_4.connect_to(s_5, edge=Edge(nonzero_predicate, increment_b_edge))
+        s_4.connect_to(s_4_1, edge=Edge(nonzero_predicate, increment_b_edge))
+        s_4.connect_to(s_4_2, edge=Edge(nonzero_predicate, increment_b_edge))
+        s_4_1.connect_to(s_5,  edge=Edge(nonzero_predicate, increment_b_edge))
+        s_4_2.connect_to(s_6,  edge=Edge(nonzero_predicate, increment_b_edge))
         s_5.connect_to(s_6, edge=Edge(nonzero_predicate, increment_b_edge))
         correct_outputs = []
         for ic in initial_conditions: