Refactor batch controller