Rewriting implementation