diff --git a/cost_function.py b/cost_function.py
index f0168bde4f8a60d7e3cbeb64cf823af680cdadba..6b731362d25bab9f8be6a4f60b85bd0217d579c3 100755
--- a/cost_function.py
+++ b/cost_function.py
@@ -37,7 +37,6 @@ def calculate_radii_rossby(list_eddies, e_overestim, handlers, array_d_init):
     avg_rad = 0 # in m
     avg_Rossby = 0
     n_valid_Rossby = 0
-    n_eddies = len(list_eddies)
 
     for n in list_eddies:
         date_index, eddy_index = report_graph.node_to_date_eddy(n, e_overestim)
@@ -60,7 +59,7 @@ def calculate_radii_rossby(list_eddies, e_overestim, handlers, array_d_init):
 
         avg_rad += R_Vmax # in m
 
-    avg_rad /= n_eddies
+    avg_rad /= len(list_eddies)
     
     if n_valid_Rossby != 0:
         avg_Rossby /= n_valid_Rossby
@@ -70,9 +69,9 @@ def calculate_radii_rossby(list_eddies, e_overestim, handlers, array_d_init):
     return {"avg_rad": avg_rad, "avg_Rossby": avg_Rossby}
 
 def get_SHPC(array_d_ini, date_index):
-    i_SHPC = bisect.bisect(array_d_init, date_index)
-    assert i_SHPC >= 1
-    return i_SHPC - 1
+    i_SHPC = bisect.bisect(array_d_init, date_index) - 1
+    assert i_SHPC >= 0
+    return i_SHPC
 
 t0 = time.perf_counter()
 timings = open("timings.txt", "w")