Changing how to publish message function works.