fixed special case divide by zero on first iteration