Fix bug with batch mode