Refactor file name retrieval