grammar refactored