Christian Krattenthaler found a way around the problem. Changing If[i <= m,mat[[i+1]] = tempvec,,]; to If[i <= m,mat[[i+1]] = tempvec,Null,Null]; seems to have fixed it. NJAS