Advanced Deluge help needed with custom function and COQL limits

Advanced Deluge help needed with custom function and COQL limits

I have a scheduled function that takes a snapshot of specific metrics and saves them to a custom module. However I'm struggling with the limits of COQL.

I attach my full code, but an example of the issues I'm having is that it's erroring with a 'Limit Exceeded' error. I believe this is because the COQL can only handle 50 records  

Full error :
{ code: 'LIMIT_EXCEEDED' , details: {...} , message: 'value limit exceeded' , status: 'error' }
code : LIMIT_EXCEEDED
details : { by: 'where' , limit: 50 }
message : value limit exceeded
status : error

This is the section of code it's referring to :
  1. // === Step 4: Query using COQL with ID filter and BANT stages
  2. varBaseCrit = "'Committed, not Signed','In Quotation (Awaiting Proposal)','In Quotation (Awaiting Response)','In Quotation (Clarify Requirements)'";
  3. varBasePayload = Map();
  4. varBasePayload.put("select_query","SELECT Total_Amount, Stage, Closing_Date, Created_Time, Deal_Name FROM Deals WHERE Stage in (" + varBaseCrit + ") AND " + varIdClause);
  5. // Send the request
  6. varBaseResponse = invokeurl
  7. [
  8.     url :"https://www.zohoapis.eu/crm/v5/coql"
  9.     type :POST
  10.     parameters:varBasePayload.toString()
  11.     connection:"REDACTED"
  12. ];
  13. info varBaseResponse;
I have several of these sections throughout the code and the number of IDs in varIdClause has hit 54 which is why it's hit this limit.

How can I fix this - is there a solution ?