Pagination fix; A little ractoring