finally get the correct nToReturn value

if command:
    1

if batch size:
    if limit:
        min(batch_size, limit)
    else:
        batch_size

0