refactor use of pubsub channels