update pagination functions: check if reach to first page or last page