diff --git a/cost_function.py b/cost_function.py
index df46b605211949f6a3d5e910f9f439a7f6bb40e1..26e616fb780ec871a1b3f90de108224eabd7529e 100755
--- a/cost_function.py
+++ b/cost_function.py
@@ -48,12 +48,11 @@ def calculate_radii_rossby(list_eddies, e_overestim, handlers, array_d_init):
         # get the radius and the rossby number:
         shapeRec = handlers[i_SHPC]["readers"]["extremum"].shapeRecord(ishape)
         f = 2 * Omega * math.sin(math.radians(shapeRec.shape.points[0][1]))
-        V_max = shapeRec.record.speed # in m/s
         radius = handlers[i_SHPC]["readers"]["max_speed_contour"]\
             .record(ishape).r_eq_area * 1000 # in m
 
-        if abs(V_max) < 100:
-            avg_Rossby += V_max / (f * radius)
+        if abs(shapeRec.record.speed) < 100:
+            avg_Rossby += shapeRec.record.speed / (f * radius)
             n_valid_Rossby += 1
 
         avg_rad += radius # in m