PH optimization changed in order to be executed after trimming