Added a possible next p value fix. Not tested