fixing bugs related to NAs