rewrite find loops with lambdas