added approximate sqrt method, and inefficient check of p1 != p2