standard pagination function to help keep things dry