diff --git a/src/avmodel.cpp b/src/avmodel.cpp
index 11a3d513ab456c9d7b98de3b1ea50f3df0ea9339..29ca1d60c94eebc3ecf36df5c2f765493df746e6 100644
--- a/src/avmodel.cpp
+++ b/src/avmodel.cpp
@@ -796,11 +796,11 @@ AVModelPimpl::stoppedDecoding(const QString& id, const QString& shmPath)
                 return; // nothing to do
             }
             if (searchFinished->second) {
-                disconnect(&*renderers_[id],
+                disconnect(&*search->second,
                            &api::video::Renderer::frameUpdated,
                            this,
                            &AVModelPimpl::slotFrameUpdated);
-                renderers_.erase(id);
+                renderers_.erase(search);
 #ifndef ENABLE_LIBWRAP
                 SIZE_RENDERER = renderers_.size();
 #endif
@@ -824,12 +824,12 @@ AVModelPimpl::slotCallStateChanged(const QString& id, const QString& state, int
         qWarning() << "Renderer " << id << "not found";
         return; // nothing to do
     }
-    if (!(*search).second->isRendering()) {
-        disconnect(&*renderers_[id],
+    if (!search->second->isRendering()) {
+        disconnect(&*search->second,
                    &api::video::Renderer::frameUpdated,
                    this,
                    &AVModelPimpl::slotFrameUpdated);
-        renderers_.erase(id);
+        renderers_.erase(search);
 #ifndef ENABLE_LIBWRAP
         SIZE_RENDERER = renderers_.size();
 #endif