search function finished