diff --git a/CEP/Pipeline/recipes/sip/bin/genericpipeline.py b/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
index 12c30f3b5dc09595c78a3491a86d9d7b179fed46..f2f85a78f6300cd06ed5c7ca22d4d9e2c41ada63 100755
--- a/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
+++ b/CEP/Pipeline/recipes/sip/bin/genericpipeline.py
@@ -3,6 +3,7 @@ import os
 import sys
 import copy
 import re
+from collections import OrderedDict
 from lofarpipe.support.parset import Parset
 from lofarpipe.support.control import control
 
@@ -504,7 +505,7 @@ class GenericPipeline(control):
         steplist = []
 
     def _replace_values(self):
-        replacedict = {}
+        replacedict = OrderedDict()
         for check in self.parset.keywords():
             if str(check).startswith('!'):
                 replacedict[str(check).lstrip('!').lstrip(' ')] = str(self.parset[check])
@@ -512,7 +513,7 @@ class GenericPipeline(control):
                 replacedict[str(check).replace('pipeline.replace.', '').lstrip(' ')] = str(self.parset[check])
         #print 'REPLACEDICT: ',replacedict
         for check in self.parset.keywords():
-            for k, v in replacedict.iteritems():
+            for k, v in reversed(replacedict.items()):
                 if '{{ '+k+' }}' in str(self.parset[check]):
                     replacestring = str(self.parset[check]).replace('{{ '+k+' }}',v)
                     self.parset.replace(check,replacestring)