proper nested loop treatment - fixes #1