Add the algorithm for createPolygon