Updated the onAfterPublish()