added publish in writeEvents