final version of pagination implemented