diff --git a/netlify.module b/netlify.module
index f0ac40b..ef9893c 100644
--- a/netlify.module
+++ b/netlify.module
@@ -6,7 +6,6 @@
  */
 
 use Drupal\Core\Entity\EntityInterface;
-use GuzzleHttp\Exception\RequestException;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
@@ -29,31 +28,26 @@ function netlify_help($route_name, RouteMatchInterface $route_match) {
 function netlify_entity_presave(EntityInterface $entity) {
   $config = \Drupal::config('netlify.settings');
   $netlify_build_hook_url = $config->get('netlify_build_hook_url');
-  $entity_type = $entity->getEntityTypeId();
 
-  $node_types = [];
-  $entity_node_types = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple();
-  foreach ($entity_node_types as $node_type) {
-    $id = $node_type->id();
-    $published_to_netlify = $config->get('netlify_node_type_' . $id);
-    if ($published_to_netlify) {
-      array_push($node_types, $id);
+  if (
+    // The build hook is setup.
+    $netlify_build_hook_url &&
+    // Content type is configured to trigger builds.
+    $entity->getEntityTypeId() === 'node' &&
+    $config->get('netlify_node_type_' . $entity->bundle()) &&
+    // Node will be published OR node was published, but will be unpublished.
+    (
+      $entity->get('status')->value ||
+      $entity->original->get('status')->value
+    )
+  ) {
+    try {
+      \Drupal::httpClient()->post($netlify_build_hook_url);
+      \Drupal::logger('netlify')->info(t('Successfully triggered Netlify build hook.'));
     }
-  }
-
-  if ($entity_type === 'node') {
-    $entity_bundle = $entity->bundle();
-    $entity_state = $entity->status->getValue()[0]['value'];
-
-    if ($entity_state === 1 && in_array($entity_bundle, $node_types)) {
-      try {
-        \Drupal::httpClient()->post($netlify_build_hook_url);
-        \Drupal::logger('netlify')->info(t('Successfully triggered Netlify build hook.'));
-      }
-      catch (RequestException $exception) {
-        \Drupal::logger('netlify')->error(t('Failed to trigger Netlify build hook due to error "%error"', ['%error' => $exception->getMessage()]));
-        return FALSE;
-      }
+    catch (\Throwable $exception) {
+      \Drupal::logger('netlify')->error(t('Failed to trigger Netlify build hook due to error "%error"', ['%error' => $exception->getMessage()]));
+      return FALSE;
     }
   }
 
