fixed bugs in event emitter