fixed env var null checks