Fixed bug with variable removal from legend