Fix bug for legend