Implementing the search() method