foldl instead of sum+map