Check if the env pointer exists before setting it