diff --git a/src/qrimageprovider.h b/src/qrimageprovider.h
index 96c99ffcac668dd747187bc52bd7f0ff65d4e343..318b98bd7eaaf3453c0309bae26e5c50ce77f7d0 100644
--- a/src/qrimageprovider.h
+++ b/src/qrimageprovider.h
@@ -78,15 +78,14 @@ public:
         } else {
             if (indexPair.second.isEmpty())
                 return QImage();
-
-            auto accountList = lrcInstance_->accountModel().getAccountList();
-            auto accountIndex = indexPair.second.toInt();
-            if (accountList.size() <= accountIndex)
+            auto accountId = indexPair.second;
+            try {
+                auto& accountInfo = lrcInstance_->getAccountInfo(accountId);
+                uri = accountInfo.profileInfo.uri;
+            } catch (const std::out_of_range&) {
+                qWarning() << "Couldn't get account info for id:" << accountId;
                 return QImage();
-
-            auto& accountInfo = lrcInstance_->accountModel().getAccountInfo(
-                accountList.at(accountIndex));
-            uri = accountInfo.profileInfo.uri;
+            }
         }
 
         if (!requestedSize.isEmpty())