fixe bug in c code