refactored code to modify groups of files at a time