correction of NaN bug