Fixed bug in createPolygon-function