fixed lambdas to only capture needed vars