added helper method to read from stream