refactor main code; add multi-threading snippet code
patmatch implements string-matching related operations