Fix a bug in event emit method