diff --git a/src/peer_discovery.cpp b/src/peer_discovery.cpp
index b5647ee8fefc3277c36da3d069b1b4b4944f3513..cb6444523e8a1e5fd7e7fd0c7b27e1067e2427a2 100644
--- a/src/peer_discovery.cpp
+++ b/src/peer_discovery.cpp
@@ -133,8 +133,7 @@ PeerDiscovery::DomainPeerDiscovery::loopListener()
             msgpack::object obj = rcv.get();
 
             if (obj.type == msgpack::type::STR) {
-                auto s = obj.as<std::string>();
-		if (!strcmp(s.c_str(), "q"))
+	        if (lrunning_ and obj.as<std::string>() == "q")
                     publish(receiveFrom_);
             } else if (obj.type == msgpack::type::MAP) {
                 for (unsigned i = 0; i < obj.via.map.size; i++) {
@@ -248,8 +247,7 @@ PeerDiscovery::DomainPeerDiscovery::stopPublish(const std::string& type)
 void
 PeerDiscovery::DomainPeerDiscovery::stopDiscovery()
 {
-    if (drunning_)
-        drunning_ = false;
+    drunning_ = false;
 }
 
 void