diff --git a/lib/Models/ArcGisMapServerCatalogItem.js b/lib/Models/ArcGisMapServerCatalogItem.js
index <HASH>..<HASH> 100644
--- a/lib/Models/ArcGisMapServerCatalogItem.js
+++ b/lib/Models/ArcGisMapServerCatalogItem.js
@@ -198,9 +198,14 @@ ArcGisMapServerCatalogItem.prototype.updateFromMetadata = function(mapServerJson
             if (!defined(thisLayerJson[i])) {
                 console.log('A layer with the name or ID \"' + layers[i] + '\" does not exist on the ArcGIS MapServer - ignoring it.');
                 thisLayerJson.splice(i, 1);
+                layers.splice(i, 1);
                 --i;
             }
         }
+
+        if (layers.length === 0) {
+            return;
+        }
     }
 
     this._mapServerData = mapServerJson;
Don't crash when no layers match.