refactoring finish batch api