Fixed searching for pattern