added code for different validation for p1 and p2