Color Sets

Trying to write a vertex lighting tool, but having trouble managing the color sets
In the code I'm checking to see if a specific color set exists.
Creating it if it doesn't, then selecting it.
Keep getting an error that the set doesn't exist.
What am I doing wrong?

CODE
string $ColorSets[] = polyColorSet -q -allColorSets;
int $AmbColorSetExists = 0;
for ($x = 0; $x < size($ColorSets); $x++){
    if ($ColorSets[$x] == "AmbColorSet") $AmbColorSetExists = 1;
}
if ($AmbColorSetExists == 0) polyColorSet -colorSet AmbColorSet -create;
updateColorSetEditor;
polyColorSet -currentColorSet AmbColorSet;

CODE
string $ColorSets[] = polyColorSet -q -allColorSets;
int $AmbColorSetExists = 0;
for ($x = 0; $x < size($ColorSets); $x++)
{
    if ($ColorSets[$x] == "AmbColorSet") $AmbColorSetExists = 1;
}
if ($AmbColorSetExists == 0)
    polyColorSet -colorSet AmbColorSet -create;
updateColorSetEditor;
polyColorSet -currentColorSet -colorSet AmbColorSet;

on the last line you forgot the -colorSet flag

Thanks a lot...
that'll be why