Refactored sum functions