added index var to addEvent