fix deprecated foreach syntax