This lambda is large enough to be awkward. Perhaps consider introducing a new local function with def instead.