fix bug when multiple .dat files