minor fix to make it work for block diagonal matrices.