moved batching logic away from API