Fix division by zero NaN error