eliminated some duplication in handleOperator, using polymorphism