diff --git a/public_html/deployment/classes/config-replacement.class.php b/public_html/deployment/classes/config-replacement.class.php
index cacacc6cd8879900edd45601c8e169deefc94a91..e8f9a675216d7f2c54f58520f519a0272feb6494 100644
--- a/public_html/deployment/classes/config-replacement.class.php
+++ b/public_html/deployment/classes/config-replacement.class.php
@@ -101,6 +101,10 @@ class configreplacement {
      */
     protected function _getForemanReplacement(){
         global $aConfig;
+        
+        $sProject = $this->_oProject->getId();
+        // echo "DEBUG: project id = $sProject<br>";
+        
         if (!$this->_sPhase){
             return false;
         }
@@ -111,12 +115,12 @@ class configreplacement {
         }
 
         // return already cached result
-        if (array_key_exists($this->_sPhase, $this->_aForemanReplacements)){
-            return $this->_aForemanReplacements[$this->_sPhase];
+        if (array_key_exists($sProject, $this->_aForemanReplacements)){
+            return $this->_aForemanReplacements[$sProject];
         }
         
         // rebuilt 
-        $this->_aForemanReplacements[$this->_sPhase]=false;
+        $this->_aForemanReplacements[$sProject]=false;
         $iEffectiveHostgroup=$this->getForemanHostgroup();
 
         // abort if no hostgroup was set
@@ -204,8 +208,12 @@ class configreplacement {
         $aYaml=spyc_load($sPart);
         // echo 'DEBUG: <pre>'.print_r($aYaml, 1).'</pre>';
 
-        $aReturn=array();
-        foreach ($aYaml as $aProject){
+       
+        if (!isset($aYaml[$sProject])){
+            return false;
+        }
+        foreach ($aYaml as $sPrjId=>$aProject){
+            $aReturn=array();
             foreach ($aProject as $sFile=>$aParams){
                 $aReturn[$sFile]=array();
                 if (array_key_exists('target', $aParams)){
@@ -222,17 +230,18 @@ class configreplacement {
                     }
                 }
             }
+            $this->_aForemanReplacements[$sPrjId]=array(
+                'phase'=>$this->_sPhase,
+                'rules'=>$aReturn,
+                'host'=>$sHost,
+                'yaml'=>$sPart,
+                'hostgroup'=>$iEffectiveHostgroup,
+                'hostsall'=>$aHosts,
+                'hostsphase'=>$aHostsOfPhase,
+            );
         }
 
-        $this->_aForemanReplacements[$this->_sPhase]=array(
-            'rules'=>$aReturn,
-            'host'=>$sHost,
-            'yaml'=>$sPart,
-            'hostgroup'=>$iEffectiveHostgroup,
-            'hostsall'=>$aHosts,
-            'hostsphase'=>$aHostsOfPhase,
-        );
-        return $this->_aForemanReplacements[$this->_sPhase];
+        return $this->_aForemanReplacements[$sProject];
     }
 
     /**