changed name and improved code for event emitter