Fix environment checking