improvement to JavaScript in events.html file