some search.php refactoring