diff --git a/src/workflow.py b/src/workflow.py
index 049e3e67d91b88c12bed10ffb6e66a0736e5e690..bc9524aa9835f6a4d0e0c04f426dcb80f26f8a1f 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -446,6 +446,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
         #Replace old analysis with new analysis (simplified code)
         self.__init__(str(temp_file), display_info = False, duplicate=True)
         self.initialise()
+        self.generate_all_graphs()
 
     def check_relevant_processes_in_workflow(self, relevant_processes):
         #Check all relevat processes are in wf
@@ -484,10 +485,41 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
         for i in range(len(parameters)):
             param = parameters[i]
             takes = subworkflow_takes[i].get_gives()[0]
-            if(takes.get_code()!=param.get_code(get_OG = True)):
+            #Here we're checking that the input inside and outside the subworkflow are the same
+            #If they are we're going to remove everything to avoid the case
+            
+            """
+            param_1 = fastq
+            sub(param_1)
+            
+            AND in the subworkflow 
+
+            sub{
+                take:
+                fastq
+            }
+            ----------
+            This would mean when removing the subworkflow def -> we would get this:
+
+            param_1 = fastq
+            fastq = param_1
+            """
+            #Obviously we want to avoid this case
+            input_val = ""
+            try:
+                input_val = param.origins[0].get_source()[0].get_origins()[0].get_name()
+            except:
+                input_val = param.get_code(get_OG = True)
+            if(takes.get_code()!=input_val):
                 new_header+=f"{takes.get_code()} = {param.get_code(get_OG = True)}"
+            else:
+                #In the case they are the same -> we remove the remaining operation (which doesn't serve a purpose)
+                #The "param_1 = fastq" operation 
+                operation_code = param.origins[0].get_source()[0].get_code()
+                code = code.replace(operation_code, "", 1)
         
-        code = code.replace(OG_call.get_code(get_OG = True), f"{new_header}\n\n{OG_body}")
+    
+        code = code.replace(OG_call.get_code(get_OG = True), f"{new_header}\n\n{OG_body}", 1)
 
         #REPLACE THE EMITS
         #TODO admittedly this code below is very moche -> but it's functionnal -> update it 
@@ -501,7 +533,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
                 if(len(emited)==1):
                     emited = emited[0]
                     if(emited.get_type()=="Emitted"):
-                        if(emited.get_emitted_by()==subworklfow):
+                        if(emited.get_emitted_by().get_first_element_called()==subworklfow):
                             if(emited.get_emits() not in emits):
                                 raise Exception("This shoudn't happen -> since it is the actual subworkflow")
                             to_replace.append((exe.get_code(get_OG = True), f"{exe.get_gives()[0].get_code()} = {emited.get_emits().get_origins()[0].get_code()}"))
@@ -586,25 +618,25 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
             for sub in broken_subworkflows:
                 code = self.rewrite_subworkflow_call(code, sub)
             
-            ##TODO -> this needs to be optimised
-            #self.rewrite_and_initialise(code)
-            ##Get the clusters and the code
-            #self.nextflow_file.generate_user_view(relevant_processes = relevant_processes, processes_2_remove =  [])
-            #clusters = self.nextflow_file.graph.get_clusters_from_user_view()
-            #    
-            #
-            #
-            ##Get the clsuters with the corresponding operations inside
-            ##for i in range(len(clusters)):
-            ##    c = clusters[i]
-            ##    if(len(c)>1):
-            ##        clusters[i] = self.nextflow_file.graph.get_induced_subgraph(c)
-            ##print(clusters)
-            ##Get the topological order
-            #clusters = self.nextflow_file.graph.get_topogical_order(clusters)
-            ##print(clusters)
-            #
-            #
+            #TODO -> this needs to be optimised
+            self.rewrite_and_initialise(code)
+            #Get the clusters and the code
+            self.generate_user_view(relevant_processes = relevant_processes, processes_2_remove =  [])
+            clusters = self.graph.get_clusters_from_user_view()
+            print(clusters)
+            
+            
+            #Get the clsuters with the corresponding operations inside
+            #for i in range(len(clusters)):
+            #    c = clusters[i]
+            #    if(len(c)>1):
+            #        clusters[i] = self.nextflow_file.graph.get_induced_subgraph(c)
+            #print(clusters)
+            #Get the topological order
+            clusters = self.graph.get_topogical_order(clusters)
+    
+
+
             ##Creating the subworkflows from clusters
             #calls_in_operations = []
             #non_relevant_name = 1