changed for loop for dict iteration. Flash didn't like it on random events