instead of for comprehensions used map/filter/fold in several places