nested loop in atmel studio