modify to move checking reserved symbols into pattern matching