diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index f9e5a3669737dbbb4d2d1cf4767f40cf45098270..1560cf5a37820f5c318257c4027c7ad6e5a33f73 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -1028,8 +1028,8 @@ JamiAccount::loadAccount(const std::string& archive_password, const std::string&
             {
                 JAMI_WARN("Auth error: %d %s", (int)error, message.c_str());
                 setRegistrationState(RegistrationState::ERROR_GENERIC);
-                runOnMainThread([w = weak()] {
-                    Manager::instance().removeAccount(w.lock()->getAccountID(), true);
+                runOnMainThread([id = getAccountID()] {
+                    Manager::instance().removeAccount(id, true);
                 });
             }, std::move(callbacks));
         }