rewrite gradient