rewrite derivatives