fix referencing deleted or nonexistent variable