C VERSION! (With logger bug)