added sorting and paging