Fix a bug with the previous commit where it would use the last entry in the list even if the entry wasn't found, and therefore wasn't going to be used.