diff --git a/python/dune/perftool/blockstructured/geometry.py b/python/dune/perftool/blockstructured/geometry.py
index ae8e06710afe6feb456d98827f7ed10ca6ade102..31f5ac01069f2feb552e1cebfe4700a43688d2c0 100644
--- a/python/dune/perftool/blockstructured/geometry.py
+++ b/python/dune/perftool/blockstructured/geometry.py
@@ -313,7 +313,8 @@ def name_point_in_macro(point_in_micro):
 
 
 def apply_constant_to_global_transformation(name, local):
-    temporary_variable(name, shape=(world_dimension(),), managed=True)
+    dim = world_dimension()
+    temporary_variable(name, shape=(dim,), managed=True)
     corners = name_element_corners()
 
     if isinstance(local, str):
@@ -324,7 +325,7 @@ def apply_constant_to_global_transformation(name, local):
     # global[d] = lower_left[d] + local[d] * (upper_right[d] - lower_left[d])
     expr = prim.Sum((prim.Subscript(prim.Variable(corners), (0,prim.Variable(d))),
                      prim.Product((prim.Subscript(local, (prim.Variable(d),)),
-                                   prim.Sum((prim.Subscript(prim.Variable(corners), (3, prim.Variable(d))),
+                                   prim.Sum((prim.Subscript(prim.Variable(corners), (2**dim - 1, prim.Variable(d))),
                                              -1 * prim.Subscript(prim.Variable(corners), (0, prim.Variable(d)))))
                                    ))
                      ))