Note that the code is doing two string comparisons here, which is unnecessary and may get expensive if the text to search is large.