Refactored to use fold