refactored how generate_files runs