fixed problem when the number of layers is different than the # of legends