added new function using foldl