Fixed conversion error of KeyError that prevented the code from running.