finish search logic