C implementation half way done