updating to make use of capability of reading from a stream