fixed a NaN condition