critical bug fix in events.js