Issue #4: Optimize the evaluation of functions