implementing code generation