fixed grammar rewriting