updated for provided grammar