add C implementation