change for in loop to for loop in eventDispatcher