# Buggy code
def calculateWhatChecker(self, length_text, key):
    """Calculates what threshold / checker to use

    If the length of the text is over the maximum sentence length, use the last checker / threshold
    Otherwise, traverse the keys backwards until we find a key range that does not fit.
    So we traverse backwards and see if the sentence length is between current - 1 and current
    In this way, we find the absolute lowest checker / percentage threshold.
    We traverse backwards because if the text is longer than the max sentence length, we already know.
    In total, the keys are only 5 items long or so. It is not expensive to move backwards, nor is it expensive to move forwards.

    Args:
        length_text -> The length of the text
        key -> What key we want to use. I.E. Phase1 keys, Phase2 keys.
    Returns:
        what_to_use -> the key of the lowest checker."""

    _keys = list(key)
    _keys = list(map(int, _keys))
    if length_text >= int(_keys[-1]):
        what_to_use = key[_keys[-1]]
    else:
        # this algorithm finds the smallest possible fit for the text
        for counter, i in reversed(list(enumerate(_keys))):
            #  [0, 110, 150]
            if i <= length_text:
                what_to_use = i
    return what_to_use


# Traceback (TypeError)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\lukas\AppData\Local\pypoetry\Cache\virtualenvs\ciphey-xvyT1_eU-py3.7\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Users\lukas\AppData\Local\pypoetry\Cache\virtualenvs\ciphey-xvyT1_eU-py3.7\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\lukas\AppData\Local\pypoetry\Cache\virtualenvs\ciphey-xvyT1_eU-py3.7\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\lukas\AppData\Local\pypoetry\Cache\virtualenvs\ciphey-xvyT1_eU-py3.7\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\ciphey.py", line 277, in main
result = decrypt(config, kwargs["text"])
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\ciphey.py", line 40, in decrypt
res: Optional[iface.SearchResult] = config.objs["searcher"].search(ctext)
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\basemods\Searchers\ausearch.py", line 214, in search
check_res = self._config().objs["checker"](ctext)
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\iface\_modules.py", line 116, in __call__
return self.check(*args)
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\basemods\Checkers\ezcheck.py", line 19, in check
res = checker.check(text)
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\basemods\Checkers\brandon.py", line 224, in check
length_text, self.thresholds_phase1.keys()
File "C:\Users\lukas\Documents\GitHub\Ciphey\ciphey\basemods\Checkers\brandon.py", line 277, in calculateWhatChecker
what_to_use = key[_keys[-1]]
TypeError: 'dict_keys' object is not subscriptable

# Fixed code
def calculateWhatChecker(self, length_text, key):
    """Calculates what threshold / checker to use

    If the length of the text is over the maximum sentence length, use the last checker / threshold
    Otherwise, traverse the keys backwards until we find a key range that does not fit.
    So we traverse backwards and see if the sentence length is between current - 1 and current
    In this way, we find the absolute lowest checker / percentage threshold.
    We traverse backwards because if the text is longer than the max sentence length, we already know.
    In total, the keys are only 5 items long or so. It is not expensive to move backwards, nor is it expensive to move forwards.

    Args:
        length_text -> The length of the text
        key -> What key we want to use. I.E. Phase1 keys, Phase2 keys.
    Returns:
        what_to_use -> the key of the lowest checker."""

    _keys = list(key)
    _keys = list(map(int, _keys))
    if length_text >= int(_keys[-1]):
        what_to_use = list(key)[_keys.index(_keys[-1])]
    else:
        # this algorithm finds the smallest possible fit for the text
        for counter, i in reversed(list(enumerate(_keys))):
            #  [0, 110, 150]
            if i <= length_text:
                what_to_use = i
    return what_to_use