adding stream backtracking (untested)