Improved pagination

I've put the current page in the middle of the pagination bar rather than at the end as it makes it clear to the user that there are more pages to come. I also cleaned up the code a bit in the function to make better use of promises.