diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c
index 7599d4ca5ea7b4f065b268d97457e3f912ca6505..5cd4566ecadd7701f9f9e4f71fd1d3c0a61943d8 100644
--- a/src/velociraptor_interface.c
+++ b/src/velociraptor_interface.c
@@ -483,11 +483,13 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) {
                   MPI_COMM_WORLD);
 #endif
 
+    const double Omega_m = e->cosmology->Omega_m;
+    const double Omega_b = e->cosmology->Omega_b;
+
     /* Linking length based on the mean DM inter-particle separation
      * in the zoom region and assuming the mean density of the Universe
      * is used in the zoom region. */
-    double mean_matter_density =
-        e->cosmology->Omega_m * e->cosmology->critical_density_0;
+    double mean_matter_density;
     if (s->with_hydro)
       mean_matter_density = (Omega_m - Omega_b) * critical_density_0;
     else