refactored calculator per suggestions