fix data reading and input/structure generation