while code generation first attempt