refactor pubnub class