started pure C implementation