using list comprehension instead of foldr