implement publish function