function unblockCards(blockedArray){
  if (blockedArray.length >= 1){
    $.each(blockedArray, function(){
      if (this === blockedArray[0]){
        $(this).removeClass("blocked");
      } else if ($(this).find(".suit").text() == $(this).next().find(".suit").text()
        && +$(this).find(".value").text() == +$(this).next().find(".value").text()+1){
        $(this).removeClass("blocked");
      } else {
        console.log("third");
        return false
      }
    });
  }
}

function findCardsToRemove(cardClicked){
  var colContents = $(cardClicked).parent()
}

$(document).ready(function(){
  
  //flip last row in each column face-up to start game
  $(".board .column").each(function(col){
    $(this).children().last().removeClass("faceDown");
  })

  //select card on click
  $(".board .column").on("click", ".card", function(){
    var $this = $(this);
    var $selected = $(".selected");

    if(!$this.hasClass("faceDown") && !$this.hasClass("blocked")){
      //for when nothing has been selected
      if($selected.length == 0){
        //select card and cards below
        $this.addClass("selected");
        $this.nextAll().addClass("selected");
      } else {
        var $firstSelected = $($selected[0]);
      // for when cards have been selected
        if($this.hasClass("selected")){
          //remove selected if clicked on selected
          $selected.removeClass("selected");
        } else if (+$this.find(".value").text() == +$firstSelected.find(".value").text()+1){
          var $blockedInCol = $firstSelected.prevAll(".blocked");
          //turn uncovered card face-up
          $selected.prev().removeClass("faceDown");
          //unblock cards
          unblockCards($blockedInCol);
          //move selected card to new column if values allow it
          $selected.appendTo($this.parent());
          $(".card").removeClass("selected");
          //block card when card is off-suit
          if ($this.find(".suit").text() != $firstSelected.find(".suit").text()){
            $firstSelected.prevAll().not(".faceDown").addClass("blocked");
          }
        }
      }
    }
  });

  //handle reserve cards
  $(".reserve .column").on("click", function(){
    var $stack = $(this);
    if(this == $(".reserve .column")[0]){
      $stack.remove();
      $.each($(".board .column"), function(){
        var card = $stack.children().first();
        card.removeClass("faceDown");
        card.remove();
        card.appendTo($(this));
      });
    }
  });

  $(".blank").on("click", function(){
    if($(".selected").length > 0){
      var $blockedInCol = $($(".selected")[0]).prevAll(".blocked");
      $(".selected").prev().removeClass("faceDown");
      $(".selected").appendTo($(this).parent());
      $(".selected").removeClass("selected");
      unblockCards($blockedInCol);
    }
  });
});
@@ -519,16 +519,140 @@
 icked)%7B%0A
+  var prev = $(cardClicked).prevAll(%22.card%22).not(%22.blocked%22);%0A  var next = $(cardClicked).nextAll(%22.card%22).not(%22.blocked%22);%0A
   var co
@@ -663,17 +663,24 @@
 tents = 
-$
+prev.add
 (cardCli
@@ -685,24 +685,780 @@
 licked).
-parent()
+add(next);%0A  var $king;%0A  $.each(colContents, function()%7B%0A    if(+$(this).find(%22.value%22).text() == 13 && !$(this).hasClass(%22faceDown%22) && !$(this).hasClass(%22blocked%22))%7B%0A      $king = $(this);%0A      checkNext($king);%0A    %7D%0A  %7D);%0A%7D%0A%0Afunction checkNext(card)%7B%0A  $eval = card.next();%0A  console.log(%22comparing the prev card %22 + card.find(%22.value%22).text() + %22with the next card %22+ $eval.find(%22.value%22).text());%0A  if($eval == null && $eval.hasClass(%22faceDown%22) && $eval.hasClass(%22blocked%22))%7B%0A    return null;%0A  %7D else if (+$eval.find(%22.value%22).text()+1 == +card.find(%22.value%22).text()%0A           && $eval.find(%22.suit%22).text() == card.find(%22.suit%22).text())%7B%0A    if (+$eval.find(%22.value%22).text == 1)%7B%0A      removeCards();%0A    %7D else %7B%0A      checkNext($eval);      %0A    %7D%0A  %7D
 %0A%7D%0A%0A$(do
@@ -2753,32 +2753,67 @@
 ss(%22selected%22);%0A
+          findCardsToRemove(this);%0A
           //bloc

create functions to find and evaluate cards to remove. still need to add function to remove the cards.