refactor sum to use left fold