fixed Pagination to make it work with all controllers