fix replacing in rewrite