convert code to C