move search and sort to utils