Add a condition to prevent too large rewriting