diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 0307270c363dd980acb16ebc5ea5e37c036c25fc..23b08b3d681d2c875f726f5c3de8ba48620bb6de 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -443,13 +443,13 @@ class OhmPiHardware:
                     # print(f'new_vab: {new_vab}, diff_vab: {diff_vab}\n')
                     if diff_vab < diff_vab_lim:
                         print('stopped on vab increase too small')
-                    else:
-                        print('stopped on maximum number of steps reached')
                 k = k + 1
                 vab_list[k] = np.min(vabs)
                 time.sleep(0.5)
                 if self.tx.pwr.voltage_adjustable:
                     self.tx.voltage = vab_list[k]
+            if k > n_steps:
+                print('stopped on maximum number of steps reached')
             vab_opt = vab_list[k]
             # print(f'Selected Vab: {vab_opt:.2f}')
             # if switch_pwr_off: