updated the prediction trimming code to abstract