adding TODO: implement Z algorithm for O(N) string matching