Don't create unnecessary closure
Merge pull request #2560 from fredj/optim

Don't create unnecessary closure