Fix bug in legend