--- a/wavelets/cell2pack.m
+++ b/wavelets/cell2pack.m
@@ -16,22 +16,39 @@
 %   level *J-2+j*.
 %
 
-JJ = length(ccell);
+[JJ bands] = size(ccell);
+JJtotal = (JJ-1)*bands + 1;
 
 [cLen, W] = size(ccell{end});
 
 
-Lc = zeros(JJ,1);
-for jj=1:JJ
-   Lc(jj) =  length(ccell{jj});
+Lc = zeros(JJtotal,1);
+Lc(1) =  length(ccell{1});
+jjIdx = 2;
+for jj=2:JJ
+    for bb=1:bands
+       Lc(jjIdx) =  length(ccell{jj,bb}(:,1));
+       jjIdx = jjIdx +1;
+    end
 end
+
 
 cvec = zeros(sum(Lc),W);
 
-lenSum = 0;
-for jj=1:JJ
-    for w=1:W
-        cvec(1+lenSum:Lc(jj)+lenSum,w) = ccell{jj}(:,w);
+for w=1:W
+    cvec(1:Lc(1),w) = ccell{1}(:,w);
+end
+
+
+for w=1:W
+ lenSumIdx = 1;
+ lenSum = Lc(lenSumIdx);
+
+ for jj=2:JJ
+    for bb=1:bands 
+        cvec(1+lenSum:Lc(lenSumIdx+1)+lenSum,w) = ccell{jj,bb}(:,w);
+        lenSum = lenSum+Lc(lenSumIdx+1);
+        lenSumIdx=lenSumIdx+1;
     end
-    lenSum = lenSum + Lc(jj);
+  end
 end