fix detectEnvironment