diff --git a/src/Controller/AJAXLinkController.php b/src/Controller/AJAXLinkController.php
index 0a79537..1db4432 100644
--- a/src/Controller/AJAXLinkController.php
+++ b/src/Controller/AJAXLinkController.php
@@ -49,18 +49,18 @@ class AJAXLinkController extends ControllerBase {
    *
    * @param \Drupal\flag\FlagInterface $flag
    *   The flag entity.
-   * @param \Drupal\Core\Entity\EntityInterface $entity
-   *   The entity to unflag.
+   * @param int $entity_id
+   *   The entity ID to unflag.
    *
    * @return AjaxResponse
    *   The response object.
    *
    * @see \Drupal\flag\Plugin\ActionLink\AJAXactionLink
    */
-  public function unflag(FlagInterface $flag, $entity) {
-
+  public function unflag(FlagInterface $flag, $entity_id) {
     $flag_service = \Drupal::service('flag');
-    $flag_service->unflag($flag, $entity);
+    $entity = $flag_service->getFlaggableById($flag, $entity_id);
+    $flag_service->unflag($flag_id, $entity_id);
 
     return $this->generateResponse('flag', $flag, $entity);
   }
