diff --git a/src/outils.py b/src/outils.py
index 120fb397d0f28630fe9d0dcfa7c2d349cb590380..65a91ba32c62747ae090066fcb7803e36e4d60cc 100644
--- a/src/outils.py
+++ b/src/outils.py
@@ -1053,7 +1053,32 @@ def process_2_DSL2(code):
 
     code = re.sub(r'file( | *\()', replace_file_by_path, code)
     code = re.sub(r'set( | *\()', replace_set_by_tuple, code)
-    return code
+    return add_vals_when_necessary(code)
+
+#Function that adds vals around variables in a tuple
+def add_vals_when_necessary(line):
+    starts_with_tuple = False
+    code_to_replace = ""
+    for match in re.finditer(r"tuple\s*\((.+)\)", line):
+        starts_with_tuple = True
+        code_to_replace = match.group(1)
+    if(not starts_with_tuple):
+        for match in re.finditer(r"tuple\s*(.+)", line):
+            starts_with_tuple = True
+            code_to_replace = match.group(1)
+    
+    if(starts_with_tuple):
+        code_to_replace = re.split(r'\,\s*emit\s*\:', code_to_replace)[0]
+        #Adding val to cases where it's just the variable
+        line_split = code_to_replace.split(',')
+        for y in range(len(line_split)) :
+            param = line_split[y]
+            if(bool(re.fullmatch('\w+', param.strip()))):
+                line_split[y] = f"val({param.strip()})"
+        temp = ", ".join(line_split)
+        line = line.replace(code_to_replace, temp)
+    return line
+
 
 
 def operation_2_DSL2(code, origin):
diff --git a/src/process.py b/src/process.py
index 4359ea669ee48a86d1968665e3903a58e2b1f30d..f7888f68bd118ee4f3d1ba7810069055a0f894e5 100644
--- a/src/process.py
+++ b/src/process.py
@@ -558,15 +558,20 @@ class Process(Nextflow_Building_Blocks):
         code = process_2_DSL2(code) 
         lines = []
         for line in code.split("\n"):
-            lines.append(line.split(" from ")[0])
+            temp = process_2_DSL2(line.split(" from ")[0]) 
+            lines.append(temp)
         code = "\n".join(lines)
         return code
     
     def convert_output_code_to_DSL2(self):
         code = self.output_code
-        code = process_2_DSL2(code) 
-        code = code.replace(" into ", ", emit: ")
-        code = code.replace(" mode flatten", "")
+        lines = []
+        for line in code.split("\n"):
+            line = line.replace(" into ", ", emit: ")
+            line = line.replace(" mode flatten", "")
+            line = process_2_DSL2(line) 
+            lines.append(line)
+        code = "\n".join(lines)
         return code
     
     #This method is to detect which are the channels which need to be flattened
diff --git a/src/workflow.py b/src/workflow.py
index 43adf837e4f092b9a588aa214374a1030b7f4be7..1a58051cf67acef3e41f4b1b1cb8f7a875f78c02 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -856,7 +856,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
                 processes_added = []
                 things_added_in_cluster = []
                 if(len(elements)>1):
-                    name, body, take, emit = "", "main:\n", "", ""
+                    name, body, take, emit = "", "", "", ""
                     first_element = True
                     for ele in elements:
 
@@ -976,9 +976,9 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
 
 
                     #Replace names inside subworkflow
-                    subworkflow_code = f"subworkflow {name} {{\n{take}\n{body}\n{emit}\n}}"
+                    subworkflow_code = f"workflow {name} {{\n{take}\nmain:\n{body}\n{emit}\n}}"
                     for i in range(len(new_param_names)):
-                        pattern = fr"[\=\,\(] *({re.escape(takes_param[i].get_code())})[\s\,\)]"
+                        pattern = fr"[\=\,\(] *({re.escape(takes_param[i].get_code())})[\s\,\)\.]"
                         subworkflow_code = replace_group1(subworkflow_code, pattern, new_param_names[i])
                         #subworkflow_code = subworkflow_code.replace(takes_param[i].get_code(), new_param_names[i])
                     
@@ -1011,7 +1011,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
                     
                 
                     print(format_with_tabs(subworkflow_code))
-                    print("-----------")
+                    print("//-----------")
                     
                     
             #TODO -> rmoving the conditions which are problematic