Change filtered sum to use reduce