This should be changed to `if legend:`.