Foldr makes it faster