diff --git a/xray/conventions.py b/xray/conventions.py
index <HASH>..<HASH> 100644
--- a/xray/conventions.py
+++ b/xray/conventions.py
@@ -57,16 +57,13 @@ def mask_and_scale(array, fill_value=None, scale_factor=None, add_offset=None,
     values = np.array(array, dtype=dtype, copy=True)
     if fill_value is not None and not np.all(pd.isnull(fill_value)):
         if getattr(fill_value, 'size', 1) > 1:
-            # multiple values in fill_value
-            for f_value in fill_value:
-                if values.ndim > 0:
-                    values[values == f_value] = np.nan
-                elif values == f_value:
-                    values = np.array(np.nan)
+            fill_values = fill_value  # multiple fill values
         else:
+            fill_values = [fill_value]
+        for f_value in fill_values:
             if values.ndim > 0:
-                values[values == fill_value] = np.nan
-            elif values == fill_value:
+                values[values == f_value] = np.nan
+            elif values == f_value:
                 values = np.array(np.nan)
     if scale_factor is not None:
         values *= scale_factor
Refactor of decoding multiple missing value logic