refactored calculator a bit