I think `in_count` should be initialized to `min(BATCH_SIZE, count)` and remove the test inside for loop