Refactored to add tests for reader