Calculate result outside the callback loop.