public string MakeSelection(Product product) { string response = ""; //Would ideally be something nicer than name comparison. Id etc var vendingProduct = Products.First(a => a.Name == product.Name); if (vendingProduct.Stock > 1) { if (Tender.Sum(a => a.Value) >= product.Price) { //this name search is being done twice and is horrible. would change //along with removing stock from product etc _productHandler.SelectProduct(Products.First(a => a.Name == product.Name)); var change = _coinHandler.MakeChange(product.Price, Tender); response = "THANK YOU"; var amountCharged = RemoveCoins(change, Tender); ChangeInMachine.AddRange(amountCharged); _coinHandler.ReturnCoins(change); Tender = new List <Coin>(); } else { response = product.Price.ToString(); } } else { if (ButtonCounter == 0) { ButtonCounter += 1; return("SOLD OUT"); } else { ButtonCounter = 0; var remaining = Tender.Sum(a => a.Value); if (remaining > 0) { return(remaining.ToString()); } else { return("INSERT COIN"); } } } return(response); }