Rewrite with lambdas and map/filter/reduce