migrate to foreach