diff --git a/src/workflow.py b/src/workflow.py
index f5eb436f46dfc720772e923b63fcadf37211ea0a..b9ae98f8818db9f4a97ef89f9b2b434cfdc2fd07 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -704,7 +704,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
             if(code.find(end_code)!=-1):
                 pos_end = code.find(end_code)
             code_to_replace = code[pos_start:pos_end]
-            for match in re.finditer(start_code_pattern, start_code):
+            for match in re.finditer(start_code_pattern, code):
                 pos_start = match.span(0)[1]+1
             #if(code.find(start_code)!=-1):
             #    pos_start = code.find(start_code)+len(start_code)