diff --git a/src/Hook/TaxonomyAccessSelectHooks.php b/src/Hook/TaxonomyAccessSelectHooks.php
new file mode 100644
index 0000000..70ef98c
--- /dev/null
+++ b/src/Hook/TaxonomyAccessSelectHooks.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Drupal\taxonomy_access_select\Hook;
+
+use Drupal\taxonomy_access_select\TaxonomyAccessSelectPermissions;
+use Drupal\taxonomy\Entity\Vocabulary;
+use Drupal\taxonomy\Entity\Term;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for taxonomy_access_select.
+ */
+class TaxonomyAccessSelectHooks
+{
+    /**
+     * Implements hook_options_list_alter().
+     */
+    #[Hook('options_list_alter')]
+    public function optionsListAlter(array &$options, array $context)
+    {
+        $fieldDefinitionSettings = $context['fieldDefinition']->getSettings();
+        if (!empty($fieldDefinitionSettings['target_type']) && $fieldDefinitionSettings['target_type'] == 'taxonomy_term') {
+            $has_access = [
+            ];
+            $vocabularies = \Drupal::entityQuery('taxonomy_vocabulary')->execute();
+            foreach ($vocabularies as $key => $vocabulary_mname) {
+                $vocabulary = \Drupal\taxonomy\Entity\Vocabulary::load($vocabulary_mname);
+                $vocabularies[$key] = $vocabulary->label();
+                $has_access[$vocabulary_mname] = \Drupal\taxonomy_access_select\TaxonomyAccessSelectPermissions::selectAccess($vocabulary_mname);
+                $has_access[$vocabulary->label()] = $has_access[$vocabulary_mname];
+            }
+            foreach ($options as $id => $names) {
+                if ($id !== '_none') {
+                    if (is_array($names)) {
+                        foreach ($names as $tid => $name) {
+                            $term = \Drupal\taxonomy\Entity\Term::load($tid);
+                            if (!$has_access[$term->bundle()]) {
+                                unset($options[$id][$tid]);
+                            }
+                        }
+                        if (empty($options[$id])) {
+                            unset($options[$id]);
+                        }
+                    } else {
+                        $term = \Drupal\taxonomy\Entity\Term::load($id);
+                        if (!$has_access[$term->bundle()]) {
+                            unset($options[$id]);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/taxonomy_access_select.info.yml b/taxonomy_access_select.info.yml
index 8bf673e..02a60f5 100644
--- a/taxonomy_access_select.info.yml
+++ b/taxonomy_access_select.info.yml
@@ -1,7 +1,7 @@
 name: Taxonomy Access Select
 type: module
 description: Allows a separate permission for term selects.
-core_version_requirement: ^8 || ^9 || ^10 || ^11
+core_version_requirement: ^10.1 || ^11 || ^12
 package: Taxonomy
 
 dependencies:
diff --git a/taxonomy_access_select.module b/taxonomy_access_select.module
index 66cd92f..eb599da 100644
--- a/taxonomy_access_select.module
+++ b/taxonomy_access_select.module
@@ -1,5 +1,7 @@
 <?php
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\taxonomy_access_select\Hook\TaxonomyAccessSelectHooks;
 use Drupal\taxonomy_access_select\TaxonomyAccessSelectPermissions;
 use Drupal\taxonomy\Entity\Vocabulary;
 use Drupal\taxonomy\Entity\Term;
@@ -7,37 +9,8 @@ use Drupal\taxonomy\Entity\Term;
 /**
  * Implements hook_options_list_alter().
  */
-function taxonomy_access_select_options_list_alter(array &$options, array $context) {
-  $fieldDefinitionSettings = $context['fieldDefinition']->getSettings();
-  if (!empty($fieldDefinitionSettings['target_type']) && $fieldDefinitionSettings['target_type'] == 'taxonomy_term') {
-    $has_access = [];
-    $vocabularies = \Drupal::entityQuery('taxonomy_vocabulary')->execute();
-    foreach ($vocabularies as $key => $vocabulary_mname) {
-      $vocabulary = Vocabulary::load($vocabulary_mname);
-      $vocabularies[$key] = $vocabulary->label();
-      $has_access[$vocabulary_mname] = TaxonomyAccessSelectPermissions::selectAccess($vocabulary_mname);
-      $has_access[$vocabulary->label()] = $has_access[$vocabulary_mname];
-    }
-    foreach ($options as $id => $names) {
-      if ($id !== '_none') {
-        if (is_array($names)) {
-          foreach ($names as $tid => $name) {
-            $term = Term::load($tid);
-            if (!$has_access[$term->bundle()]) {
-              unset($options[$id][$tid]);
-            }
-          }
-          if (empty($options[$id])) {
-            unset($options[$id]);
-          }
-        }
-        else {
-          $term = Term::load($id);
-          if (!$has_access[$term->bundle()]) {
-            unset($options[$id]);
-          }
-        }
-      }
-    }
-  }
+#[LegacyHook]
+function taxonomy_access_select_options_list_alter(array &$options, array $context)
+{
+    \Drupal::service(TaxonomyAccessSelectHooks::class)->optionsListAlter($options, $context);
 }
diff --git a/taxonomy_access_select.services.yml b/taxonomy_access_select.services.yml
index 7b74672..4200eaa 100644
--- a/taxonomy_access_select.services.yml
+++ b/taxonomy_access_select.services.yml
@@ -5,3 +5,7 @@ services:
       arguments: ['@plugin.manager.entity_reference_selection']
       decorates: entity.autocomplete_matcher
       decoration_priority: 1
+
+  Drupal\taxonomy_access_select\Hook\TaxonomyAccessSelectHooks:
+    class: Drupal\taxonomy_access_select\Hook\TaxonomyAccessSelectHooks
+    autowire: true
