fix bug in code generator