reorder conditional to handle NaN or Infinite