re-structuring of code using PubSub