Fixing bug where the event is not attached