c backend working but needs tidied