now the codegen in the correct place