Calculator refactor