Fixed division by 0 yielding infinity ending up as for loop argument causing infinite loop crash.