added support for writing events