Fix NaN problem on some datasets