add search and sort code