fix bug in add() method/
fix bug in add() method

taking the condition when p1 or p2 is O into consideration