upgraded the C code to r36