Added if braces.
Changed check whether p1 p2 p3 are collinear.