Finish search function