fix code generation optimization