Fixed bug in createClosedPolygon