Fixed division by NaN bug