Added a proper c program to do this right