Replaced sort with search function