Hi i'm programming a match-3 game using Lite-C and i have the following inexplicable problem: here's the part of the code that's causing the crash i don't understand:

 Code:
//row number 4, n=22 to n=28
while(n>21 && n<=28)
{
wait(1);                     // give a small delay before creation
randomize(); c = random(3);  //random number for creation, 'c' is an int
create_ball = c;
	
if(c==0){balls[n] = ent_create("gem_r.mdl",vector((n-21)*40,0,0),rotate_me);}
if(c==1){balls[n] = ent_create("gem_g.mdl",vector((n-21)*40,0,0),rotate_me);}
if(c==2){balls[n] = ent_create("gem_b.mdl",vector((n-21)*40,0,0),rotate_me);}
if(c==3){balls[n] = ent_create("gem_w.mdl",vector((n-21)*40,0,0),rotate_me);}
		
me = balls[n];       //declare a pointer to the created ball
my.skill11 = c;      //defines the 'type' so that match-3 can be checked
my.tilt=90;          //only because it looks better this way :)
balls[n][1] = my.x;  //store the co-ordinates in arrays to be accessed later
balls[n][2] = my.y;
n+=1;                //keep incrementing 'n'
wait(1);
}

//row number 5, n=29 to n=35
while(n>28 && n<=35)
{
wait(1);
randomize(); c = random(3);
create_ball = c;
	
if(c==0){balls[n] = ent_create("gem_r.mdl",vector((n-28)*40,-40,0),rotate_me);}
if(c==1){balls[n] = ent_create("gem_g.mdl",vector((n-28)*40,-40,0),rotate_me);}
if(c==2){balls[n] = ent_create("gem_b.mdl",vector((n-28)*40,-40,0),rotate_me);}
if(c==3){balls[n] = ent_create("gem_w.mdl",vector((n-28)*40,-40,0),rotate_me);}
		
me = balls[n];
my.skill11 = c;
my.tilt=90;
balls[n][1] = my.x;
balls[n][2] = my.y;
n+=1;
wait(1);
}


here 'n' is indicative of the row number. i have 7 rows. Whenever 'n' reaches 'n+7', it moves to the next row. I copy-pasted the code 7 times so that 7 rows are created. All the rows create the 'gems' and work fine except for the 5th, which causes a 'Crash in (function name)'. If the 5th row creation code is deleted, it works fine and creates the gems in rows 6 and 7. And here's the funny part: if the 5th row code is included, it creates gems until n reaches '33' and then crashes i.e. it creates 4 gems in the 5th row before crashing.

Since i've copy-pasted the code, there shouldn't be a syntax error. I've gone through the code many many times and just can't find the problem. What might be going wrong?

By the way, thanks to Quadraxas for refering me to Lite-C. Its made the programming of this game a lot easier (except for 'Crash in Main' and 'Crash in (function name)) \:\)