moved ps1 code into separate file