rewritting event emitter