Got rid of unaccessible code by using the TryGetValue method as intended.