fixed potential bug with errors thrown when trying to delete a legend if one has not been added