minor optimization of the inner-loop.