Refactored the reading part