check variables exist before using