Creating the publish function