C code updated and working