diff --git a/src/finite-strain-elasticity.cc b/src/finite-strain-elasticity.cc
index 3d7bf5a5e1cbd4bf988a534783998297695ce8e2..bf6c6b445e42ff6263f48f0d37a0cde0e1501e7b 100644
--- a/src/finite-strain-elasticity.cc
+++ b/src/finite-strain-elasticity.cc
@@ -146,9 +146,6 @@ int main (int argc, char *argv[]) try
   BitSetVector<1> dirichletVertices(gridView.size(dim), false);
   BitSetVector<1> neumannVertices(gridView.size(dim), false);
 
-  GridType::Codim<dim>::LeafIterator vIt    = gridView.begin<dim>();
-  GridType::Codim<dim>::LeafIterator vEndIt = gridView.end<dim>();
-
   const GridView::IndexSet& indexSet = gridView.indexSet();
 
   // Make Python function that computes which vertices are on the Dirichlet boundary,
@@ -160,15 +157,15 @@ int main (int argc, char *argv[]) try
   lambda = std::string("lambda x: (") + parameterSet.get<std::string>("neumannVerticesPredicate", "0") + std::string(")");
   PythonFunction<FieldVector<double,dim>, bool> pythonNeumannVertices(Python::evaluate(lambda));
 
-  for (; vIt!=vEndIt; ++vIt)
+  for (auto&& v : vertices(gridView))
   {
     bool isDirichlet;
-    pythonDirichletVertices.evaluate(vIt->geometry().corner(0), isDirichlet);
-    dirichletVertices[indexSet.index(*vIt)] = isDirichlet;
+    pythonDirichletVertices.evaluate(v.geometry().corner(0), isDirichlet);
+    dirichletVertices[indexSet.index(v)] = isDirichlet;
 
     bool isNeumann;
-    pythonNeumannVertices.evaluate(vIt->geometry().corner(0), isNeumann);
-    neumannVertices[indexSet.index(*vIt)] = isNeumann;
+    pythonNeumannVertices.evaluate(v.geometry().corner(0), isNeumann);
+    neumannVertices[indexSet.index(v)] = isNeumann;
   }
 
   BoundaryPatch<GridView> dirichletBoundary(gridView, dirichletVertices);