add the function of pagination