refactor CodeGenerator