implementation of search pattern