fixed rewrite method