refactor -- added pubsub.flush