Fixing polygon code