Just something that stands out for me is the two end closing brackets in the if statement
you currently have this:

if(p1 != p2)[COLOR="Red"])[/COLOR] {

and you should have this?
if(p1 != p2) {