fix bug in ps code