added rewriting