rewrite g