Refactoring reading logic