replaced pid with trid throughout