diff --git a/python/pystencils_walberla/boundary.py b/python/pystencils_walberla/boundary.py
index 329b6805984e24fcdc4e4d17205ec55aa29cff06..ee035a636a6ed08372999594352a971836777ec0 100644
--- a/python/pystencils_walberla/boundary.py
+++ b/python/pystencils_walberla/boundary.py
@@ -97,7 +97,7 @@ def generate_boundary(generation_context,
         'inner_or_boundary': boundary_object.inner_or_boundary,
         'single_link': boundary_object.single_link,
         'additional_data_handler': additional_data_handler,
-        'dtype': "double" if is_float else "float",
+        'dtype': "float" if is_float else "double",
         'layout': layout
     }
 
diff --git a/python/pystencils_walberla/templates/Boundary.tmpl.h b/python/pystencils_walberla/templates/Boundary.tmpl.h
index 03b403aeac1797acd4e429be140a8e35c63d4cb6..f454a975da5bbb9cd7649378c4644dfb8c9d53a9 100644
--- a/python/pystencils_walberla/templates/Boundary.tmpl.h
+++ b/python/pystencils_walberla/templates/Boundary.tmpl.h
@@ -238,10 +238,12 @@ public:
         {%endif%}
         {%else%}
         auto flagWithGLayers = flagField->xyzSizeWithGhostLayer();
+        {% if single_link %}
         {{dtype}} dot = 0.0; {{dtype}} maxn = 0.0;
         cell_idx_t calculated_idx = 0;
         cell_idx_t dx = 0; cell_idx_t dy = 0; {%if dim == 3%}  cell_idx_t dz = 0; {% endif %}
         cell_idx_t sum_x = 0; cell_idx_t sum_y = 0; {%if dim == 3%} cell_idx_t sum_z = 0; {%endif %}
+        {% endif -%}
         for( auto it = flagField->beginWithGhostLayerXYZ(); it != flagField->end(); ++it )
         {
             {% if single_link -%}