completed stream part of homework - corrected earlier version