Rewrite using C