Sets up pagination