diff --git a/src/code_.py b/src/code_.py
index f5a3250844b8a17861e0c54c0354351ac837eaa1..519be9ebb6cf2550e440eb4e0cb854c0706d1bf9 100644
--- a/src/code_.py
+++ b/src/code_.py
@@ -194,7 +194,14 @@ class Code:
         for r in to_replace:
             old, new = r
             self.add_to_ternary_operation_dico(old, new)
+            tmp = code
             code = code.replace(old, new)
+            if(old!=new and tmp==code):
+                raise Exception("This shouldn't happen -> the code wasn't replaced")
+        #Check if there is still a ternary operation in this case we cannot analyse it
+        #Cause it is a complexe/multiple ternanry operation
+        for match in re.finditer(pattern, code):
+            raise BioFlowInsightError("Detected a multi ternary operation (a ternary operation in a ternary operation). BioFlow-Insight does not support this, try defining it in a different way.", type="Multi ternary operation")
         return code
 
     def rewrite_jump_dot(self, code):
diff --git a/src/workflow.py b/src/workflow.py
index 73c97d7fb8c21494a021fd883e92a72f96b120f1..976170dbd3935b9f2cc374515eda43580b0dcc7f 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -761,8 +761,12 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
                 raise Exception("This shoudn't happen -> either a call to a process or subworkflow outside of main or subworkflow")
 
         #Simplifying main
-        code = code.replace(self.get_workflow_main().get_code(get_OG = True), self.get_workflow_main().simplify_code())
-
+        tmp = code
+        old = self.get_workflow_main().get_code(get_OG = True)
+        new = self.get_workflow_main().simplify_code()
+        code = code.replace(old, new)
+        if(tmp==code and old!=new):
+            raise Exception("This shouldn't happen -> code not replaced")
 
         #Adding processes into code
         for p in processes:
@@ -872,7 +876,10 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
     def rewrite_subworkflow_call(self, code, subworklfow):
         
         #Remove the defintion from the code
+        tmp = code
         code = code.replace(subworklfow.get_code(get_OG = True), "")
+        if(tmp==code):
+            raise Exception("This shouldn't happen")
         OG_call = subworklfow.get_call()
         OG_body = subworklfow.get_work()