check if variable exists before getting it