Revise output with grammar