nested loop counter