Fix search

Minor fix:
* error handling with 's'=>'sb' and 'h'=>'hb'
* improve code readability