Edit function for fix bug caused by NaN values, so, the NaN values are replaced by zero value.