Build Grid with Random Boxes

I'm starting to pull my hair out trying to build a grid with random boxes. The script that I was able to come up with so far randomly places a duplicated mc but they will be placed ontop of each other. Can someone please give me help and give me some advice on what I might be doing wrong and which direction I should be going in? I would be very greatfull for the help. Here is what I have been able to come up with so far.

-----Code-----

function buildGrid() {

var xStart:Number = getProperty(box_mc, _x);

var yStart:Number = getProperty(box_mc, _y);

var xSpacing:Number = 10;

var ySpacing:Number = 10;

var v:Number = 0;

var i:Number = -1;

while (++i<32) {

var j:Number = -1;

while (++j<17) {

++v;

var box:String = "grid"+v;

var boxDepth:Number = getDepth(box_mc);

if (boxDepth == 1) {

_root.box_mc.duplicateMovieClip(box, v);

_root[box]._x = xStart+random(i)*xSpacing;

_root[box]._y = yStart+random(j)*ySpacing;

_root[box].gotoAndPlay(v);

} else if (_root[box] != 1) {

removeMovieClip(_root[box]);

}

}

}

}