If you're trying to avoid the lowercase stuff, you can also check for the '>' in the appropriate positions. This will also work as a quick check that the string ends at the appropriate location which will exclude anything that's not a </head> most of the time. You could even apply this comparison before the '/' comparison to avoid the '/' comparison which gives a true result for all closing tags rather than only closing tags with the same length as "</head>".