udpated ps_open function