finalized text search algorithm