changed all the foldleft calls to simpler list comprehention