diff --git a/admin_toolbar_tools/admin_toolbar_tools.module b/admin_toolbar_tools/admin_toolbar_tools.module
index 9d68e3a..802975e 100644
--- a/admin_toolbar_tools/admin_toolbar_tools.module
+++ b/admin_toolbar_tools/admin_toolbar_tools.module
@@ -454,6 +454,83 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
       );
     }
   }
+  $manager = \Drupal::service('plugin.manager.menu.local_task');
+  foreach ($links as $key => $link) {
+    if (isset($link['route_name'])  ) {
+      $route = $link['route_name'];
+      $primary = $manager->getLocalTasks($route, 0);
+      foreach ($primary['tabs'] as $tab) {
+        if ($tab['#link']['url']) {
+          $local_route = $tab['#link']['url']->getRouteName();
+          if ($local_route) {
+            $exists = false;
+            $param=false;
+            if (isset($link['route_parameters'])) {
+              $param=$link['route_parameters'];
+              $links[$key . '_' . $local_route]['route_parameters'] = $link['route_parameters'];
+            }
+            // Check if this local task does not have an
+            // already registered link in admin toolbar
+            foreach ($links as $link2) {
+              //route_name Could be a 'class'
+              if (isset($link2['route_name']) && ($link2['route_name'] == $local_route)) {
+                //If route are equal, the parameters could be different
+                // todo: check if this is true.
+                if($param){
+                  if(isset($link2['route_parameters']) && ($param==$link2['route_parameters'])){
+                    $exists = true;
+                    break;
+                  }
+                }else{
+                  $exists = true;
+                  break;
+                }
+              }
+            }
+            $parent=false;
+            if (!$exists) {
+              $title = $tab['#link']['title'];
+              $title=$param?$title.' '.$link['title']:$title;
+              $menu=isset($link['menu_name'])?$link['menu_name']:'admin';
+              
+              //the following code is to choose the parent of the added link.
+              //if the parent of the current tab have also the tab as local task
+              //   ex: "Content" have "File" as task" 
+              //       and "Content>Comment" have also "File" as tab
+              //then we decide to set this one as parent of the added link
+              //if not the current tab will be the parent 
+              if(isset($link['parent'])){
+                $parentlink=$links[$link['parent']];
+                $parentlink_route = $parentlink['route_name'];
+                $parent_primary = $manager->getLocalTasks($parentlink_route, 0);
+                foreach ($parent_primary['tabs'] as $parent_tab) {
+                  if ($parent_tab['#link']['url']) {
+                    $parent_route = $parent_tab['#link']['url']->getRouteName();
+                    if($parent_route==$local_route){
+                      $parent=$link['parent'];
+                      break;
+                    }
+                  }
+                }
+              }
+              $parent=$parent?$parent:$key;
+              //make sure the key of the route is unique
+              $links[$key . '_' . $local_route] = array(
+                'title' => $title, 
+                'route_name' => $local_route, 
+                'menu_name' => $menu, 
+                'parent' => $parent
+              );
+              if ($param) {
+                $links[$key . '_' . $local_route]['route_parameters'] = $param;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
 }
 
 /**
@@ -483,4 +560,4 @@ function getLinks($entity_type_id) {
   $links = $entity->getLinkTemplates();
 
   return $links;
-}
\ No newline at end of file
+}
