This is far from ideal but I'm not sure what a better way would be to loop twice over the events...