updated rewrite