Modified combine2 to permute dimensions at end and combine3 to concatenate individual variables