pubsub refactor