diff --git a/mqtt_interface.py b/mqtt_interface.py
index 6968a29594eee7647f3b9d03c4c2960ed4ac57d5..1eaf661e0ff77dde8caca622d110dee08d1cb876 100644
--- a/mqtt_interface.py
+++ b/mqtt_interface.py
@@ -6,6 +6,7 @@ import zmq
 
 ctrl_queue = Queue()
 
+
 def on_message(client, userdata, message):
     global socket
 
@@ -17,6 +18,7 @@ def on_message(client, userdata, message):
     reply = socket.recv()
     print(f'Received reply {message.payload.decode("utf-8")}: {reply}')
 
+
 mqtt_client = mqtt.Client(f'ohmpi_{OHMPI_CONFIG["id"]}_listener', clean_session=False)  # create new instance
 print('connecting command listener to broker')
 trials = 0
@@ -24,14 +26,15 @@ trials_max = 10
 broker_connected = False
 while trials < trials_max:
     try:
-        mqtt_client.username_pw_set(MQTT_CONTROL_CONFIG['auth'].get('username'),MQTT_CONTROL_CONFIG['auth']['password'])
+        mqtt_client.username_pw_set(MQTT_CONTROL_CONFIG['auth'].get('username'),
+                                    MQTT_CONTROL_CONFIG['auth']['password'])
         mqtt_client.connect(MQTT_CONTROL_CONFIG['hostname'])
         trials = trials_max
         broker_connected = True
     except:
         print('trying again...')
         time.sleep(2)
-        trials+=1
+        trials += 1
 if broker_connected:
     print('Subscribing to topic', MQTT_CONTROL_CONFIG['ctrl_topic'])
     mqtt_client.subscribe(MQTT_CONTROL_CONFIG['ctrl_topic'], MQTT_CONTROL_CONFIG['qos'])
@@ -45,7 +48,7 @@ if broker_connected:
     socket.connect(f'tcp://localhost:{CONTROL_CONFIG["tcp_port"]}')
 
     while True:
-       time.sleep(.1)
+        time.sleep(.1)
 else:
     print("Unable to connect to broker")
     exit(1)
diff --git a/ohmpi.py b/ohmpi.py
index 8293095243d399c7c305bca929fbe10c69d71c3a..4905f1c9bd0f52ba466f66b3df577b56a368e8b2 100644
--- a/ohmpi.py
+++ b/ohmpi.py
@@ -745,7 +745,7 @@ class OhmPi(object):
                 # measure all quadrupole of the sequence
                 for i in range(0, self.sequence.shape[0]):
                     quad = self.sequence[i, :]  # quadrupole
-                    if self.run is False:
+                    if self.status == 'stopping':
                         break
 
                     # call the switch_mux function to switch to the right electrodes