fix the legend bug