second iteration of code, includes processing multiple files