cleaned up code generation for while