function filter_nans added