UI fix: change from for to foreach