bug fix in c code