nested loops in atmel studio