Use mutable lambdas and avoid pointers