fix crash in legend