implement basic readable stream interface
refactoring