setting p1 and p2