accounted for NaN problem