Optimize whole functions