working publish method