Added docs and changed the search loop condition.