Completed search function.