diff --git a/dune/istl/matrixredistribute.hh b/dune/istl/matrixredistribute.hh
index 511b529989a524cdbd8067b1b840813ce8648716..0a6b4faee1b4ab6f4864bdd4a5414a04a7f9fe2f 100644
--- a/dune/istl/matrixredistribute.hh
+++ b/dune/istl/matrixredistribute.hh
@@ -446,10 +446,16 @@ namespace Dune
           {
             *c=0;
             if(c.index()==i->local()) {
-              typedef typename M::block_type::RowIterator RIter;
-              for(RIter r=c->begin(), rend=c->end();
-                  r != rend; ++r)
-                (*r)[r.index()]=1;
+              typedef typename M::block_type Block;
+              Hybrid::ifElse(IsNumber<Block>(),
+                             [&](auto id){
+                               *c = 1;
+                             },
+                             [&](auto id){
+                               for(auto r=c->begin(), rend=c->end();
+                                   r != rend; ++r)
+                                 (*r)[r.index()]=1;
+                             });
             }
           }
         }
diff --git a/dune/istl/test/matrixredisttest.cc b/dune/istl/test/matrixredisttest.cc
index ba52ae5cf86d7d6591f4bb410a7e03c8dd9f281c..5b9159535fa848eece97d530a5276684ab8e79ad 100644
--- a/dune/istl/test/matrixredisttest.cc
+++ b/dune/istl/test/matrixredisttest.cc
@@ -34,25 +34,22 @@ void MPI_err_handler(MPI_Comm *, int *err_code, ...){
   throw MPIError(s, *err_code);
 }
 
-template<int BS>
+template<class MatrixBlock>
 int testRepart(int N, int coarsenTarget)
 {
 
   std::cout<<"==================================================="<<std::endl;
-  std::cout<<"BS="<<BS<<" N="<<N<<" coarsenTarget="<<coarsenTarget<<std::endl;
+  std::cout<<" N="<<N<<" coarsenTarget="<<coarsenTarget<<std::endl;
 
   int procs, rank;
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Comm_size(MPI_COMM_WORLD, &procs);
 
-  typedef Dune::FieldMatrix<double,BS,BS> MatrixBlock;
   typedef Dune::BCRSMatrix<MatrixBlock> BCRSMat;
   typedef Dune::bigunsignedint<56> GlobalId;
   typedef Dune::OwnerOverlapCopyCommunication<GlobalId> Communication;
   int n;
 
-  N/=BS;
-
   Communication comm(MPI_COMM_WORLD);
 
   BCRSMat mat = setupAnisotropic2d<MatrixBlock>(N, comm.indexSet(), comm.communicator(), &n, 1);
@@ -138,6 +135,8 @@ int main(int argc, char** argv)
     return 1;
   }
 
-  testRepart<1>(N,coarsenTarget);
+  testRepart<Dune::FieldMatrix<double, 1, 1>>(N,coarsenTarget);
+  testRepart<Dune::FieldMatrix<double, 2, 2>>(N/2,coarsenTarget);
+  testRepart<double>(N,coarsenTarget);
   MPI_Finalize();
 }