Added search and sort function