improve code generation part