refactored to simple ReadWriteStream