Changed formal functions to lambdas