calculator refactored