fixed broken foreach