complete pagination implementation