I am sorry for an incomplete proposal. The stricter check if (check.margin && any(dims[MARGIN]!=dimstat)) { was meant to be if (check.margin && (length(dimstat)!=length(MARGIN) || any(dims[MARGIN]!=dimstat))) { Petr.