Added pure C implementation