Fix a bug in handling event state