refactoring to read from a . file