fixed up search function