fix bug in PublishMessage