better rewriting