c implementation