removed the need to call apply_rewrite from the client code