refactor in terms of foldl