migrate from `for` to `foreach` or `do`