public static UserBehavior GetNextUser() { UserBehavior first_user = null; bool gotit = false; foreach (KeyValuePair <string, UserBehavior> entry in user_dict) { UserBehavior user = entry.Value; if (!user.IsActiveUser()) { continue; } if (gotit) { current_user = user; return(user); } if (first_user == null) { first_user = user; } if (current_user == null) { current_user = user; return(user); } if (user == current_user) { gotit = true; } } current_user = first_user; return(first_user); }