added checking for max number of colors