updating algorithm for adding filenames to a set