Refactor calculator