Reduce environment captured by nested function