some changes to only write non NaN number