fix small input error; add preliminary indexing for matches