added support for multiple palettes