correcting a code emission bug related to nested loops and while statements