Fully implemented search function.