diff --git a/ProcessLib/CreateDeactivatedSubdomain.cpp b/ProcessLib/CreateDeactivatedSubdomain.cpp
index 47fa3e0f7782d36b1954d8708833287cd13fd5d2..32cec4d861cf83128b12821f253074c7889e5660 100644
--- a/ProcessLib/CreateDeactivatedSubdomain.cpp
+++ b/ProcessLib/CreateDeactivatedSubdomain.cpp
@@ -91,7 +91,7 @@ static std::vector<std::vector<std::size_t>> extractElementsAlongOuterNodes(
 
 static DeactivatedSubdomainMesh createDeactivatedSubdomainMesh(
     MeshLib::Mesh const& mesh,
-    std::vector<int> const& deactivated_subdomain_material_ids)
+    std::unordered_set<int> const& deactivated_subdomain_material_ids)
 {
     // An element is active if its material id matches one of the deactivated
     // subdomain material ids.
@@ -99,11 +99,8 @@ static DeactivatedSubdomainMesh createDeactivatedSubdomainMesh(
         [&deactivated_subdomain_material_ids,
          &material_ids = *materialIDs(mesh)](std::size_t element_id)
     {
-        int const element_material_id = material_ids[element_id];
-        return std::any_of(begin(deactivated_subdomain_material_ids),
-                           end(deactivated_subdomain_material_ids),
-                           [&](int const material_id)
-                           { return material_id == element_material_id; });
+        return deactivated_subdomain_material_ids.contains(
+            material_ids[element_id]);
     };
 
     auto const& elements = mesh.getElements();
@@ -271,7 +268,8 @@ DeactivatedSubdomain createDeactivatedSubdomain(
 
     auto deactivated_subdomain_material_ids =
         //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__material_ids}
-        config.getConfigParameter("material_ids", std::vector<int>{});
+        config.getConfigParameter("material_ids", std::vector<int>{}) |
+        ranges::to<std::unordered_set>();
 
     if (deactivated_subdomain_material_ids.empty())
     {
@@ -280,9 +278,6 @@ DeactivatedSubdomain createDeactivatedSubdomain(
             "program terminates now.");
     }
 
-    std::sort(deactivated_subdomain_material_ids.begin(),
-              deactivated_subdomain_material_ids.end());
-
     if (materialIDs(mesh) == nullptr)
     {
         OGS_FATAL(