fix C code bug