getting rid of terminal/nonterminal polymorphism