diff --git a/tools.py b/tools.py
index 4f1b284415455447681e031a08a1a723006bde6b..792271dfe4e42edb928abba6c5ef3868978b32ab 100644
--- a/tools.py
+++ b/tools.py
@@ -128,6 +128,7 @@ class Main:
                 self.fit_avg.update_value(fit_error)
         else:
             roundness = 0
+            fit_error = -1
             max_int, num_pix = (0, 0)
             linearity = "No ions"
 
@@ -641,6 +642,9 @@ def dark_ions(image, coord, dist_factor):
         #     warnings.warn("Loss is too high... "
         #     "Try calculating a new factor value using calibrate() function.")
 
+    else:
+        loss = np.array([-1])
+
     return coord, loss.min()