Should be able to make this significantly faster by building an indexed dictionary before searching through it with indexOf.