Added check for getSelectedEnvironment()