refactored readers and writers into single class