fix file handling