change the code to c style