Updated Polygon checking code code