Change two free functions to lambdas