refactor file creation