fix bug in events.js