Fixed deletion logic on variables