Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 4da35bce2f399383ece20220161d3f98edb34fe6)
+++ sansview/perspectives/fitting/fitting.py	(revision ef16f59a1f741d95c71ad8fe4eb5e71c643740b0)
@@ -118,4 +118,5 @@
         self.state_reader = None 
         self.temp_state = []
+        self.state_index = 0
         # Log startup
         logging.info("Fitting plug-in started") 
@@ -301,30 +302,33 @@
         
         """
-        #print "state", state
-        #return
-        #working on reading state
-        self.temp_state = []
-        try: 
-            # state
+        # store fitting state in temp_state
+        self.temp_state.append(state) 
+        # index to start with for a new set_state
+        self.state_index = 0
+
+    def  on_set_state_helper(self,event=None):
+        """
+        Set_state_helper. This acutally sets state after plotting data from state file.
+        
+        : event: FitStateUpdateEvent called by plot_data from guiframe, data_loader
+        """
+        if self.temp_state == None or len(self.temp_state) == 0:
+            return
+        try:
             # Load fitting state
-            self.temp_state.append(state) 
-            # Make sure the user sees the fitting panel after loading
-            #self.parent.set_perspective(self.perspective)   
-                   
+            state = self.temp_state[self.state_index]
+            #set state
+            page = self.fit_panel.set_state(state) 
+            # get ready for the next set state
+            self.state_index += 1
+            
+            #reset state variables to default when all set_state is finished. 
+            if len(self.temp_state) == self.state_index:
+                self.temp_state = []
+                # Make sure the user sees the fitting panel after loading
+                self.parent.set_perspective(self.perspective) 
         except:
+            self.temp_state = [] 
             raise
-        
-    def  on_set_state_helper(self,event=None):
-        """
-        """
-        if self.temp_state == None:
-            return
-        # Load fitting state
-        for index in range(len(self.temp_state)):
-            page = self.fit_panel.set_state(self.temp_state[index]) 
-            # Make sure the user sees the fitting panel after loading
-            self.parent.set_perspective(self.perspective)  
-             
-        self.temp_state = []   
                  
     def save_fit_state(self, filepath, fitstate):  
Index: sansview/perspectives/fitting/pagestate.py
===================================================================
--- sansview/perspectives/fitting/pagestate.py	(revision 4da35bce2f399383ece20220161d3f98edb34fe6)
+++ sansview/perspectives/fitting/pagestate.py	(revision ef16f59a1f741d95c71ad8fe4eb5e71c643740b0)
@@ -1139,5 +1139,6 @@
                     if max_char < 0:
                         max_char = len(state.file)
-                    state.file = state.file[0:max_char] +' [' + time_str + ']'
+                    original_fname = state.file[0:max_char]
+                    state.file = original_fname +' [' + time_str + ']'
                    
                         
@@ -1149,14 +1150,15 @@
                     state.data.name = output[ind].filename #state.data_name
                     state.data.id = state.data_id
-                    state.data.id = state.data_id
                     if state.is_data is not None:
                         state.data.is_data = state.is_data
-                    state.data.group_id = output[ind].filename
-                  
-                    # make sure to put run name if none
-                    #if output[ind].run == None or output[ind].run ==[]:
-                    #    exec 'output[%d].run = [output[%d].filename]'% (ind,ind)
+                    if output[ind].run_name is not None and len(output[ind].run_name) != 0 :
+                        name = output[ind].run_name
+                    else: 
+                        name=original_fname
+                    state.data.group_id = name
+                    #store state in fitting
                     self.call_back(state=state, datainfo=output[ind])
-                return output[ind]
+                    
+                return output
               
         except:
@@ -1176,5 +1178,5 @@
             
             # Add fitting information to the XML document
-            self.write_toXML(datainfo, fitstate)
+            doc = self.write_toXML(datainfo, fitstate)
             # Write the XML document
             fd = open(filename, 'w')
