Calculate refactored