Generating randomly placed circles. without them overlapping

for(var a=0; a<counter; a++){

	for(var b=0; b&lt;100; b++){ 

	    var scanXpositions = (storedXPositions[a] - 50) + b;   
	    var scanYpositions = (storedYPositions[a] - 50) + b;

		if((xValue == scanXpositions) || (yValue == scanYpositions)){
	
		  xValue = randomness(650);
		 
   	          yValue = randomness(450);

			 trace("corrected");
			  a = 0;
		}
	
	}
 trace(a);
}

THis is what I have but it times out. I think it’s because it has to scan every x/y value a circle would take up…

There has to be a more efficient way of doing this? Like a built in function that detects overlap?