extending powershell and refactor