Fix bug in codegen