cleaned up publish/unpublish logic