Folding the list instead of using for