modified stream match to avoid dict backtracking