diff --git a/src/code_.py b/src/code_.py
index 7a9dd14daa845eb13852d5c66742c1ec9acc4159..7d734dcd73545e6409c81db3495304837bff4d35 100644
--- a/src/code_.py
+++ b/src/code_.py
@@ -34,21 +34,88 @@ class Code:
    
     #This methods turns a single line condition into a muli line conditions 
     def turn_single_condition_into_multiline(self, code):
-
-        pattern = r"(if *\()(.+)\n"
+        
         to_replace = []
-        for match in re.finditer(pattern, code):
-            all = match.group(0)
-            extarcted = match.group(2).strip()
+
+        start = 0
+
+        curly_count, parenthese_count = 0, 0
+        quote_single, quote_double = False, False
+        triple_single, triple_double = False, False
+
+
+        while(start<len(code)):         
+            checked_triple = False
+            if(start+3<=len(code)):
+                if(code[start:start+3]=="'''" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    triple_single = True
+                    start+=3
+                    checked_triple = True
+                elif(code[start:start+3]=="'''" and not quote_single and not quote_double and triple_single and not triple_double):
+                    triple_single = False
+                    start+=3
+                    checked_triple = True
+        
+                if(code[start:start+3]=='"""' and not quote_single and not quote_double and not triple_single and not triple_double):
+                    triple_double = True
+                    start+=3
+                    checked_triple = True
+                elif(code[start:start+3]=='"""' and not quote_single and not quote_double and not triple_single and triple_double):
+                    triple_double = False
+                    start+=3
+                    checked_triple = True
             
-            if(extarcted!="" and extarcted[-1] not in ["{", "}"]):
-                start, end = match.span(1)
-                extracted_condition = get_code_until_parenthese_count(code=code[end:], val=-1)
-                condition = extracted_condition[:-1]
-                body = extarcted.replace(extracted_condition.strip(), "")
-                if(body!="" and body[0]!="{"):
-                    new = f"if ({condition}) {{\n{body}\n}}\n"
-                    to_replace.append((all, new))
+            if(not checked_triple):
+                if(code[start]=="{" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    curly_count+=1
+                elif(code[start]=="}" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    curly_count-=1
+                
+                if(code[start]=="(" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    parenthese_count+=1
+                elif(code[start]==")" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    parenthese_count-=1
+        
+                if(code[start]=="'" and not quote_single and not quote_double and not triple_single and not triple_double):
+                    if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")):
+                        quote_single=True
+                elif(code[start]=="'" and quote_single and not quote_double and not triple_single and not triple_double):
+                    if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")):
+                        quote_single=False
+        
+                if(code[start]=='"' and not quote_single and not quote_double and not triple_single and not triple_double):
+                    if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")):
+                        quote_double=True
+                elif(code[start]=='"' and not quote_single and quote_double and not triple_single and not triple_double):
+                    if(code[start-1]!="\\" or (code[start-1]=="\\" and code[start-2]=="\\")):
+                        quote_double=False
+
+       
+                if(code[start:start+2]=="if" and [quote_single, quote_double, triple_single, triple_double]==[False, False, False, False]):
+
+                    pattern = r"(if *\()(.+)\n"
+        
+                    temp_code = code[start:]
+                    for match in re.finditer(pattern, temp_code):
+                        if(match.span(0)[0]==0):
+                            found_if_bloc = True
+                            all = match.group(0)
+                            extarcted = match.group(2).strip()
+                            
+                            if(extarcted!="" and extarcted[-1] not in ["{", "}"]):
+                                _, end_condition = match.span(1)
+                                extracted_condition = get_code_until_parenthese_count(code=temp_code[end_condition:], val=-1)
+                                condition = extracted_condition[:-1]
+                                body = extarcted.replace(extracted_condition.strip(), "")
+                                if(body!="" and body[0]!="{"):
+                                    new = f"if ({condition}) {{\n{body}\n}}\n"
+                                    to_replace.append((all, new))
+                                    
+                            
+                start+=1
+
+
+        
         for r in to_replace:
             old, new = r
             code = code.replace(old, new)
diff --git a/src/process.py b/src/process.py
index ec693ed614f6de064641db7568d4a42c040aec6c..d81cd614b06b3ce6a5b20b12aadc0f9a1ad00272 100644
--- a/src/process.py
+++ b/src/process.py
@@ -60,6 +60,10 @@ class Process(Nextflow_Building_Blocks):
         else:
             raise Exception("This shouldn't happen")
 
+    
+    def add_to_ternary_operation_dico(self, old, new):
+        self.nextflow_file.add_to_ternary_operation_dico(old, new)
+
     def add_to_emits(self, emit):
         self.later_emits.append(emit)