Refactoring sum to make it more similar to product