fix name of to_dat() function