added logic for empty palettes