Checking if variables exist before referencing them