fixed a bug in demo code generation