Reduce nested functions