fixed rewriting