diff --git a/mvcm/scene.py b/mvcm/scene.py
index ff5808ed034eb2c0697cd8af3a69de93002b63a2..7206c9aa27c24691de3d8ffc294bc7ac7990a1bf 100644
--- a/mvcm/scene.py
+++ b/mvcm/scene.py
@@ -133,7 +133,7 @@ class IdentifyPixels:
             coast_scene,
         )
 
-        coast_scene = xr.where(uniformity < 0, 1, coast_scene)
+        coast_scene = xr.where(uniformity <= 0, 1, coast_scene)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return coast_scene.astype(np.ubyte)
@@ -178,7 +178,7 @@ class IdentifyPixels:
             water_scene,
         )
 
-        water_scene = xr.where(uniformity < 0, 0, water_scene).astype(np.ubyte)
+        water_scene = xr.where(uniformity <= 0, 0, water_scene).astype(np.ubyte)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return water_scene
@@ -358,7 +358,7 @@ class IdentifyPixels:
             land_scene,
         )
 
-        land_scene = xr.where(uniformity < 0, 1, land_scene).astype(np.ubyte)
+        land_scene = xr.where(uniformity <= 0, 1, land_scene).astype(np.ubyte)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return land_scene
diff --git a/mvcm/utility_functions.py b/mvcm/utility_functions.py
index 186dd43c0fe457437d2cbb4002122d43553b994a..2b25e4c46ade3260a103ba0d1475f2ce3bc39592 100644
--- a/mvcm/utility_functions.py
+++ b/mvcm/utility_functions.py
@@ -6,6 +6,8 @@ import numpy as np
 import xarray as xr
 from numpy.lib.stride_tricks import sliding_window_view
 
+from mvcm.constants import ConstantsNamespace
+
 logger = logging.getLogger(__name__)
 
 
@@ -26,6 +28,7 @@ def cloud_mask_spi(data: xr.Dataset):
         m07.coarsen(number_of_lines=2, number_of_pixels=2).std()
         / m07.coarsen(number_of_lines=2, number_of_pixels=2).mean()
     )
+    spi = xr.where(np.isnan(spi), ConstantsNamespace.BAD_DATA, spi)
     return spi