diff --git a/src/jamidht/account_manager.cpp b/src/jamidht/account_manager.cpp
index 18052585999cb150644dc8ee3d54e172fe563ce7..d20f0f9f294b18005006ebc474fb366de2caf02b 100644
--- a/src/jamidht/account_manager.cpp
+++ b/src/jamidht/account_manager.cpp
@@ -724,7 +724,7 @@ AccountManager::forEachDevice(
 
     struct State
     {
-        unsigned remaining {0};
+        unsigned remaining {1}; // Note: state is initialized to 1, because we need to wait that the get is finished
         std::set<dht::PkId> treatedDevices {};
         std::function<void(const std::shared_ptr<dht::crypto::PublicKey>&)> onDevice;
         std::function<void(bool)> onEnd;
@@ -767,7 +767,9 @@ AccountManager::forEachDevice(
             });
             return true;
         },
-        [state](bool /*ok*/) { state->ended(); });
+        [state](bool /*ok*/) {
+            state->found({});
+        });
 }
 
 void