diff --git a/include/QueryGenerator/EnhancedQueryGenerator.php b/include/QueryGenerator/EnhancedQueryGenerator.php
index a9f8c3f9ba065812ef54467403cc216fca2c8499..bf4878364c1301b5739e60cfbc53f5199c41aa40 100644
--- a/include/QueryGenerator/EnhancedQueryGenerator.php
+++ b/include/QueryGenerator/EnhancedQueryGenerator.php
@@ -623,6 +623,7 @@ class EnhancedQueryGenerator extends QueryGenerator {
 		foreach ($this->conditionals as $index => $conditionInfo) {
 			$parentReferenceField = '';
 			$baseFieldName = $fieldName = $conditionInfo['name'];
+			$parentReferenceField = $referenceModule = '';
 			$field = $moduleFieldList[$fieldName];
 
 			// if its a reference field then we need to add the fieldname to table name