Changes to events.js, not working well yet