Refactored query component to fully utilise pubsub component