Fixed race condition with publish/query