Corrected logic for unpublish and somewhat also for publish