Improved substring search