pubsub refactored