cleaned up events.js a little