Fix a bug in the IndexOf function.