first implentation of pagination