Refactored sum into its own method