Fixed logic of inner block calculation loop.

Signed-off-by: tyduptyler13 <tyduptyler13@yahoo.com>