small change to check if var exists before setting old value