make lambda capturing more robust