nested loops, not parsed correctly, fixed