some preliminary refactoring of calculator