diff --git a/MeshLib/Utils/SetMeshSpaceDimension.cpp b/MeshLib/Utils/SetMeshSpaceDimension.cpp
index 3c522c2f1e19375786631bd98ddc7a4482e84f74..745c3fdc5bc39a013042b8290acde401e13bff7d 100644
--- a/MeshLib/Utils/SetMeshSpaceDimension.cpp
+++ b/MeshLib/Utils/SetMeshSpaceDimension.cpp
@@ -11,6 +11,8 @@
 
 #include "SetMeshSpaceDimension.h"
 
+#include <range/v3/algorithm/for_each.hpp>
+
 #include "GetSpaceDimension.h"
 #include "MeshLib/Elements/Element.h"
 #include "MeshLib/Mesh.h"
@@ -20,14 +22,11 @@ namespace MeshLib
 void setMeshSpaceDimension(std::vector<std::unique_ptr<Mesh>> const& meshes)
 {
     // Get the space dimension from the bulk mesh:
-    auto const space_dimension = getSpaceDimension(meshes[0]->getNodes());
+    auto const d = getSpaceDimension(meshes[0]->getNodes());
     for (auto const& mesh : meshes)
     {
-        auto elements = mesh->getElements();
-        for (auto element : elements)
-        {
-            element->space_dimension_ = space_dimension;
-        }
+        ranges::for_each(mesh->getElements(),
+                         [d](Element* const e) { e->space_dimension_ = d; });
     }
 }
 };  // namespace MeshLib