Null guard in Publish function