fixing bugs in dataset generation code