code generation refactoring