Adding C implementation