refine sort logic & prepare for search logic