public void SelectKerbal()
            {
                if (kerbalSelected)
                {
                    return;
                }
                kerbalSelected = true;

                // First, try to get a Kerbal that matches the name
                if (!string.IsNullOrEmpty(characterName))
                {
                    kerbal = HighLogic.CurrentGame.CrewRoster.AllKerbals().Where(pcm => pcm.name == characterName).FirstOrDefault();
                }
                // Now grab from the active vessel
                else if (kerbal == null && FlightGlobals.ActiveVessel != null)
                {
                    kerbal = FlightGlobals.ActiveVessel.GetVesselCrew().Where(pcm => !excludeName.Contains(pcm.name)).ElementAtOrDefault(crewIndex);

                    if (kerbal != null)
                    {
                        characterName = kerbal.name;
                    }
                }

                if (kerbal == null && string.IsNullOrEmpty(characterName))
                {
                    System.Random r = new System.Random();
                    gender        = r.Next(2) == 0 ? ProtoCrewMember.Gender.Male : ProtoCrewMember.Gender.Female;
                    characterName = Kerbal.KerbalName(gender);
                }
            }