repair basic algorithm of p-1 method