pagination implementation, now working