implementing pagination helper