fixed advanced search function