Ps1 refactoring