replace lambdas with r.func