diff --git a/client.go b/client.go
index <HASH>..<HASH> 100644
--- a/client.go
+++ b/client.go
@@ -324,7 +324,7 @@ func (c *Client) doRequest(req *http.Request, emptyResponse bool) (interface{}, 
 		var values []interface{}
 		for {
 			values = append(values, responsePaginated.Values...)
-			if responsePaginated.Pagelen == 0 || responsePaginated.Size/responsePaginated.Pagelen <= responsePaginated.Page {
+			if len(responsePaginated.Next) == 0 {
 				break
 			}
 			newReq, err := http.NewRequest(req.Method, responsePaginated.Next, nil)
@@ -336,6 +336,8 @@ func (c *Client) doRequest(req *http.Request, emptyResponse bool) (interface{}, 
 			if err != nil {
 				return resBody, err
 			}
+
+			responsePaginated = &Response{}
 			json.NewDecoder(resp).Decode(responsePaginated)
 		}
 		responsePaginated.Values = values
Don't reuse response struct for multiple requests (#<I>)

A fix was added in <URL>).



The actual problem was that the `responsePaginated` variable was being reused in the loop, and the json decoder doesn't overwrite fields that aren't present in the response, so it was the `Next` field would end up with the value from the previous page, causing the same page to be requested forever.