refactored code to ignore open files and entirely use generators.