I wrote a function which returns me a record ID which is in the PENDING state (the column state). And it should limit active downloads (records that are in states S
state