diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 9afee70c80874d590e007de3e96fc2495764f1a8..20bf2888646bf2ca73a69bdf57a91f8dd70b5c0f 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -2602,10 +2602,10 @@ JamiAccount::getCertificatesByStatus(tls::TrustStore::PermissionStatus status)
 }
 
 template<typename ID = dht::Value::Id>
-std::set<ID>
+std::set<ID, std::less<>>
 loadIdList(const std::string& path)
 {
-    std::set<ID> ids;
+    std::set<ID, std::less<>> ids;
     std::ifstream file = fileutils::ifstream(path);
     if (!file.is_open()) {
         JAMI_DBG("Could not load %s", path.c_str());
@@ -2626,9 +2626,9 @@ loadIdList(const std::string& path)
     return ids;
 }
 
-template<typename ID = dht::Value::Id>
+template<typename List = std::set<dht::Value::Id>>
 void
-saveIdList(const std::string& path, const std::set<ID>& ids)
+saveIdList(const std::string& path, const List& ids)
 {
     std::ofstream file = fileutils::ofstream(path, std::ios::trunc | std::ios::binary);
     if (!file.is_open()) {
@@ -2660,14 +2660,14 @@ JamiAccount::saveTreatedMessages() const
             auto& this_ = *sthis;
             std::lock_guard<std::mutex> lock(this_.messageMutex_);
             fileutils::check_dir(this_.cachePath_.c_str());
-            saveIdList<std::string>(this_.cachePath_ + DIR_SEPARATOR_STR "treatedMessages",
+            saveIdList<decltype(this_.treatedMessages_)>(this_.cachePath_ + DIR_SEPARATOR_STR "treatedMessages",
                                     this_.treatedMessages_);
         }
     });
 }
 
 bool
-JamiAccount::isMessageTreated(const std::string& id)
+JamiAccount::isMessageTreated(std::string_view id)
 {
     std::lock_guard<std::mutex> lock(messageMutex_);
     auto res = treatedMessages_.emplace(id);
diff --git a/src/jamidht/jamiaccount.h b/src/jamidht/jamiaccount.h
index e6ccbe073402056be01d3f598e6676c39a4f4afb..c41ee250e7aad2b46f38f7d1119b5ea93f54c0b5 100644
--- a/src/jamidht/jamiaccount.h
+++ b/src/jamidht/jamiaccount.h
@@ -390,7 +390,7 @@ public:
     /// \return true if the given DHT message identifier has been treated
     /// \note if message has not been treated yet this method store this id and returns true at
     /// further calls
-    bool isMessageTreated(const std::string& id);
+    bool isMessageTreated(std::string_view id);
 
     std::shared_ptr<dht::DhtRunner> dht() { return dht_; }
 
@@ -727,7 +727,7 @@ private:
 
     mutable std::mutex messageMutex_ {};
     std::map<dht::Value::Id, PendingMessage> sentMessages_;
-    std::set<std::string> treatedMessages_ {};
+    std::set<std::string, std::less<>> treatedMessages_ {};
 
     std::string deviceName_ {};
     std::string idPath_ {};