brute force search substring algorithm