added a first draft of the c code