Fixed bug in code-gen