refactoring and testing on file reading and processing.