diff --git a/Elwig/Helpers/Billing/EditBillingData.cs b/Elwig/Helpers/Billing/EditBillingData.cs
index c3b8f1e..5be462f 100644
--- a/Elwig/Helpers/Billing/EditBillingData.cs
+++ b/Elwig/Helpers/Billing/EditBillingData.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json.Nodes;
 
@@ -16,7 +17,7 @@ namespace Elwig.Helpers.Billing {
             return new(ParseJson(json), attributeVariants);
         }
 
-        public IEnumerable<GraphEntry> GetPaymentGraphEntries() {
+        public IEnumerable<GraphEntry> GetPaymentGraphEntries(AppDbContext context) {
             Dictionary<int, List<string>> dict1 = [];
             Dictionary<decimal, List<string>> dict2 = [];
             var p = GetPaymentEntry();
@@ -40,22 +41,38 @@ namespace Elwig.Helpers.Billing {
                 dict2[idx].Add("default");
             }
 
+            var virtOffset = dict1.Count;
             Dictionary<int, Curve> curves = GetCurves();
             decimal[] virtCurves = [.. dict2.Keys.Order()];
             for (int i = 0; i < virtCurves.Length; i++) {
                 var idx = virtCurves[i];
-                dict1[1000 + i] = dict2[idx];
-                curves[1000 + i] = new Curve(CurveMode.Oe, new() { { 73, idx } }, null);
+                dict1[i + virtOffset] = dict2[idx];
+                curves[i + virtOffset] = new Curve(CurveMode.Oe, new() { { 73, idx } }, null);
             }
 
-            Dictionary<int, List<string>> dict3 = [];
+            Dictionary<int, List<string>> dict3 = curves.ToDictionary(c => c.Key, _ => new List<string>());
+            foreach (var (selector, value) in GetSelection(p, AttributeVariants)) {
+                int? idx = null;
+                if (value.TryGetValue<decimal>(out var val)) {
+                    idx = Array.IndexOf(virtCurves, val) + virtOffset;
+                } else if (value.TryGetValue<string>(out var str)) {
+                    idx = int.Parse(str.Split(":")[1]);
+                }
+                if (idx != null)
+                    dict3[(int)idx].Add(selector);
+            }
 
+            var vars = context.WineVarieties.ToDictionary(v => v.SortId, v => v);
+            var attrs = context.WineAttributes.ToDictionary(a => a.AttrId, a => a);
 
-
-            return dict3.Select(e => new GraphEntry(e.Key, curves[e.Key], 50, 120)).ToList();
+            return dict3
+                .Select(e => new GraphEntry(e.Key, curves[e.Key], e.Value
+                    .Select(s => new ContractSelection(vars[s[..2]], s.Length > 2 ? attrs[s[2..]] : null))
+                    .ToList(), 50, 120))
+                .ToList();
         }
 
-        public IEnumerable<GraphEntry> GetQualityGraphEntries() {
+        public IEnumerable<GraphEntry> GetQualityGraphEntries(AppDbContext context) {
             Dictionary<int, List<string>> dict1 = [];
             Dictionary<decimal, List<string>> dict2 = [];
             foreach (var (qualid, q) in GetQualityEntry() ?? []) {
diff --git a/Elwig/Helpers/Billing/GraphEntry.cs b/Elwig/Helpers/Billing/GraphEntry.cs
index 05dae82..eb86887 100644
--- a/Elwig/Helpers/Billing/GraphEntry.cs
+++ b/Elwig/Helpers/Billing/GraphEntry.cs
@@ -31,11 +31,12 @@ namespace Elwig.Helpers.Billing {
             if (gebunden != null) GebundenGraph = new Graph(gebunden, minX, maxX);
         }
 
-        public GraphEntry(int id, BillingData.Curve curve, int minX, int maxX) :
+        public GraphEntry(int id, BillingData.Curve curve, List<ContractSelection> contracts, int minX, int maxX) :
             this(id, curve.Mode, minX, maxX) {
             DataGraph = new Graph(curve.Normal, minX, maxX);
             if (curve.Gebunden != null)
                 GebundenGraph = new Graph(curve.Gebunden, minX, maxX);
+            Contracts = contracts;
         }
 
         private GraphEntry(int id, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
diff --git a/Elwig/Windows/ChartWindow.xaml.cs b/Elwig/Windows/ChartWindow.xaml.cs
index b78e237..3945d89 100644
--- a/Elwig/Windows/ChartWindow.xaml.cs
+++ b/Elwig/Windows/ChartWindow.xaml.cs
@@ -58,10 +58,7 @@ namespace Elwig.Windows {
 
         private async Task RefreshGraphList() {
             await Context.PaymentVariants.LoadAsync();
-            await RefreshGraphListQuery();
-        }
 
-        private async Task RefreshGraphListQuery() {
             var attrVariants = Context.DeliveryParts
                 .Where(d => d.Year == Year)
                 .Select(d => $"{d.SortId}{d.AttrId}")
@@ -71,37 +68,18 @@ namespace Elwig.Windows {
                 .Order()
                 .ToList();
             var data = EditBillingData.FromJson(PaymentVar.Data, attrVariants);
-            GraphEntries.AddRange(data.GetPaymentGraphEntries());
-            GraphEntries.AddRange(data.GetQualityGraphEntries());
+            GraphEntries = [ ..data.GetPaymentGraphEntries(Context), ..data.GetQualityGraphEntries(Context)];
 
-            //var contracts = ContractSelection.GetContractsForYear(Context, Year).DistinctBy(c => c.Listing).Order().ToList();
-            //ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as GraphEntry)?.Id);
-
-            ControlUtils.RenewItemsSource(ContractInput, attrVariants, g => g);
-            ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.IfOnly);
+            var contracts = ContractSelection.GetContractsForYear(Context, Year).DistinctBy(c => c.Listing).Order().ToList();
+            ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.ToString());
+            ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.First);
 
             RefreshInputs();
         }
 
-        private string ParseContracts(JsonObject auszahlungsSorten, int num) {
-            return "";
-        }
-       
-        private void RefreshInputs(bool validate = false) {
+        private void RefreshInputs() {
             ResetPlot();
-            if (!PaymentVar.TestVariant) {
-                AddButton.IsEnabled = false;
-                CopyButton.IsEnabled = false;
-                DeleteButton.IsEnabled = false;
-                DisableUnitTextBox(OechsleInput);
-                DisableUnitTextBox(PriceInput);
-                GebundenTypeFixed.IsEnabled = false;
-                GebundenTypeGraph.IsEnabled = false;
-                GebundenTypeNone.IsEnabled = false;
-                ContractInput.IsEnabled = false;
-                EnableOptionButtons();
-                FillInputs();
-            } else if (SelectedGraphEntry != null) {
+            if (SelectedGraphEntry != null) {
                 CopyButton.IsEnabled = true;
                 DeleteButton.IsEnabled = true;
                 //EnableUnitTextBox(OechsleInput);
@@ -117,21 +95,31 @@ namespace Elwig.Windows {
                 DisableUnitTextBox(OechsleInput);
                 DisableOptionButtons();
             }
-            GC.Collect();
+            if (!PaymentVar.TestVariant) {
+                AddButton.IsEnabled = false;
+                CopyButton.IsEnabled = false;
+                DeleteButton.IsEnabled = false;
+                DisableUnitTextBox(OechsleInput);
+                DisableUnitTextBox(PriceInput);
+                GebundenTypeFixed.IsEnabled = false;
+                GebundenTypeGraph.IsEnabled = false;
+                GebundenTypeNone.IsEnabled = false;
+                ContractInput.IsEnabled = false;
+            }
         }
 
         private void FillInputs() {
-            GraphNum.Text = SelectedGraphEntry.Id.ToString();
+            GraphNum.Text = SelectedGraphEntry?.Id.ToString();
 
-            if (SelectedGraphEntry.GebundenFlatBonus != null) {
+            if (SelectedGraphEntry?.GebundenFlatBonus != null) {
                 GebundenTypeFixed.IsChecked = true;
-            } else if (SelectedGraphEntry.GebundenGraph != null) {
+            } else if (SelectedGraphEntry?.GebundenGraph != null) {
                 GebundenTypeGraph.IsChecked = true;
             } else {
                 GebundenTypeNone.IsChecked = true; ;
             }
 
-            ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry.Contracts, i => (i as ContractSelection)?.Listing);
+            ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry?.Contracts ?? [], i => (i as ContractSelection)?.Listing);
 
             InitPlot();
             OechslePricePlot.IsEnabled = true;
@@ -149,13 +137,13 @@ namespace Elwig.Windows {
                 GebundenPlot.MarkerSize = 9;
             }
 
-            DataPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry.DataGraph.DataX, SelectedGraphEntry.DataGraph.DataY);
+            DataPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry!.DataGraph.DataX, SelectedGraphEntry!.DataGraph.DataY);
             DataPlot.LineColor = Color.Blue;
             DataPlot.MarkerColor = Color.Blue;
             DataPlot.MarkerSize = 9;
 
-            if (SelectedGraphEntry.GebundenGraph == null) {
-                ChangeActiveGraph(SelectedGraphEntry.DataGraph);
+            if (SelectedGraphEntry?.GebundenGraph == null) {
+                ChangeActiveGraph(SelectedGraphEntry?.DataGraph);
             }
 
             OechslePricePlot.RightClicked -= OechslePricePlot.DefaultRightClickEvent;
@@ -470,7 +458,7 @@ namespace Elwig.Windows {
                 HighlightedPointPlot.IsVisible = true;
                 HoverChanged = true ^ HoverActive;
                 HoverActive = true;
-                HandleTooltip(mouseOnGebunden.Value.x, mouseOnGebunden.Value.y, mouseOnGebunden.Value.index, SelectedGraphEntry!.GebundenGraph);
+                HandleTooltip(mouseOnGebunden.Value.x, mouseOnGebunden.Value.y, mouseOnGebunden.Value.index, SelectedGraphEntry!.GebundenGraph!);
             } else {
                 ChangeMarker(HighlightedPointPlot, false);
                 HoverChanged = false ^ HoverActive;
@@ -604,7 +592,7 @@ namespace Elwig.Windows {
         }
 
         private void GraphList_SelectionChanged(object sender, SelectionChangedEventArgs e) {
-            SelectedGraphEntry = (GraphEntry)GraphList.SelectedItem;
+            SelectedGraphEntry = GraphList.SelectedItem as GraphEntry;
             RefreshInputs();
 
             //var x = OechslePricePlot.Plot.GetPlottables().OfType<ScatterPlot>();
@@ -629,6 +617,7 @@ namespace Elwig.Windows {
         private void ContractInput_Changed(object sender, RoutedEventArgs e) {
             var r = ContractInput.SelectedItems.Cast<ContractSelection>();
             SelectedGraphEntry!.Contracts = r.ToList();
+            // FIXME when using arrow keys, selection does not work nicely
             GraphList.Items.Refresh();
         }