avoid recursion in rewrite, thanks Jonathan