factorize auto batcher and make it less error prone