C-Code I had around on google drive