powershell loop refactor