Begin converting function to c