search function finished v2