Add comments to clarify nested loops