re-organized to run for batch_size > 1
added dumping