fix polygon writing