Adjust the function to work in the batch.