Fixed a bug where event was not defined