Calculator refactored