Refactored get_directory_of_files