updated to work the same as Cpalette