fix 'event is not defined' error