pagination stops at last page and first page