ENYO-3082: save next function in a closure (safeNext)