refactor file loading