Fixes bug in legend