diff --git a/src/CalcStats.py b/src/CalcStats.py
index f8a3d66fabbe3ec072e605e6ea871b2c2d56fe82..cb513e299e83995b8c4106cddac3b022b0ce0eee 100755
--- a/src/CalcStats.py
+++ b/src/CalcStats.py
@@ -497,36 +497,36 @@ class DeviceObj:
 			attribute = self.prefix()+'{:03d}_MinMax_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 			val = np.roll(val, -1);val[-1] = self.minmax; selfseq_dev.write_attribute(attribute,val)
 
-			if self.tag == SENSOR_TAG:
-				for target in target_dev:
-					if target.enable == True:
-						if self.enable_targets & (1 << target.index):
+			if self.tag == SENSOR_TAG:		
+				for target in target_dev:				
+					if target.enable == True:					
+						if self.enable_targets & (1 << target.index):						
 							attribute='s{:03d}_t{:03d}_Corr'.format(self.index+1,target.index+1)
-							selfseq_dev.write_attribute(attribute,self.corr[target.index]);
+							selfseq_dev.write_attribute(attribute,self.corr[target.index]);						
 							attribute='s{:03d}_t{:03d}_CorrFiltAbs'.format(self.index+1,target.index+1)
-							selfseq_dev.write_attribute(attribute,self.lp_filter_corr[target.index]);	
+							selfseq_dev.write_attribute(attribute,self.lp_filter_corr[target.index]);								
 							attribute='s{:03d}_t{:03d}_CorrHigh'.format(self.index+1,target.index+1)
-							selfseq_dev.write_attribute(attribute,self.corr_high[target.index]);
+							selfseq_dev.write_attribute(attribute,self.corr_high[target.index]);						
 							attribute='s{:03d}_t{:03d}_CorrLow'.format(self.index+1,target.index+1)
-							selfseq_dev.write_attribute(attribute,self.corr_low[target.index]);
+							selfseq_dev.write_attribute(attribute,self.corr_low[target.index]);							
 							attribute='s{:03d}_t{:03d}_Direction'.format(self.index+1,target.index+1)
 							selfseq_dev.write_attribute(attribute,self.sensor_direction[target.index]);
-
+							
 							# History for Corr, CorrFiltAbs, CorrLow, CorrHigh
 							# corr
-							attribute = self.prefix()+'s{:03d}_t{:03d}_Corr_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute ='s{:03d}_t{:03d}_Corr_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value							
 							val = np.roll(val, -1);val[-1] = self.corr[target.index]; selfseq_dev.write_attribute(attribute,val)
 	
 							# corrfiltabs							
-							attribute = self.prefix()+'s{:03d}_t{:03d}_CorrFiltAbs_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 's{:03d}_t{:03d}_CorrFiltAbs_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.lp_filter_corr[target.index]; selfseq_dev.write_attribute(attribute,val)
 	
 							# corrlow								
-							attribute = self.prefix()+'s{:03d}_t{:03d}_CorrLow_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 's{:03d}_t{:03d}_CorrLow_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.corr_low[target.index]; selfseq_dev.write_attribute(attribute,val)
 
 							# corrhigh																	
-							attribute = self.prefix()+'s{:03d}_t{:03d}_CorrHigh_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 's{:03d}_t{:03d}_CorrHigh_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.corr_high[target.index]; selfseq_dev.write_attribute(attribute,val)								
 
 			elif self.tag == TARGET_TAG:
@@ -546,19 +546,19 @@ class DeviceObj:
 
 							# History for Corr, CorrFiltAbs, CorrLow, CorrHigh
 							# corr
-							attribute = self.prefix()+'t{:03d}_t{:03d}_Corr_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 't{:03d}_t{:03d}_Corr_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.corr[target.index]; selfseq_dev.write_attribute(attribute,val)
 	
 							# corrfiltabs							
-							attribute = self.prefix()+'t{:03d}_t{:03d}_CorrFiltAbs_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 't{:03d}_t{:03d}_CorrFiltAbs_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.lp_filter_corr[target.index]; selfseq_dev.write_attribute(attribute,val)
 	
 							# corrlow								
-							attribute = self.prefix()+'t{:03d}_t{:03d}_CorrLow_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 't{:03d}_t{:03d}_CorrLow_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.corr_low[target.index]; selfseq_dev.write_attribute(attribute,val)
 
 							# corrhigh																	
-							attribute = self.prefix()+'t{:03d}_t{:03d}_CorrHigh_History'.format(self.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
+							attribute = 't{:03d}_t{:03d}_CorrHigh_History'.format(self.index+1,target.index+1); val = selfseq_dev.read_attribute(attribute); val = val.value
 							val = np.roll(val, -1);val[-1] = self.corr_high[target.index]; selfseq_dev.write_attribute(attribute,val)