rough implementation of batch