runs in outer loop; parameters in inner loop