some refactoring on the code generation