partial c implementation