added 'addEvents' function