fixed advanced search by refactoring existing search