search function working properly