   }
   
   func updateSection(_ section: Int) {
-    if expandedCells[section] == .Expanded {
-      expandedCells[section] = .Collapse
+    if expandedCells[section] == .expanded {
+      expandedCells[section] = .collapse
     } else {
-      expandedCells[section] = .Expand
+      expandedCells[section] = .expand
     }
     tableView.reloadSections(IndexSet(integer: section), with: .fade)
     tableView.scrollToRow(at: IndexPath(row: 0, section: section), at: .top, animated: true)

      })
    }
    answerTextViewBottom.constant = 20
    update(arrow: .Up, animated: animated)
  }
  
  func expand(withAttributedAnswer attributedAnswer: NSAttributedString, animated: Bool) {
    answerTextView.attributedText = attributedAnswer
    answerTextView.isHidden = false
    if animated {
      answerTextView.alpha = 0
      UIView.animate(withDuration: 0.5, animations: {
        self.answerTextView.alpha = 1
      })
    }
    answerTextViewBottom.constant = 20
    update(arrow: .Up, animated: animated)
  }
  
  func collapse(animated: Bool) {
    answerTextView.text = ""
    answerTextView.isHidden = true
    answerTextViewBottom.constant = -30
    update(arrow: .Down, animated: animated)
  }
  
  func update(arrow: Arrow, animated: Bool) {
    switch arrow {
    case .Up:
      self.indicatorImageView.rotate(withAngle: CGFloat(M_PI), animated: animated)
    case .Down:
      self.indicatorImageView.rotate(withAngle: CGFloat(0), animated: animated)
    }
  }
}

enum Arrow: String {
  case Up
  case Down
}

enum CellOperation {
  case Default
  case Expand
  case Expanded
  case Collapse
}

extension UIImageView {

    self.titleLabel.backgroundColor = configuration.titleLabelBackgroundColor
    self.backgroundColor = configuration.viewBackgroundColor
    self.tableView.separatorStyle = .none
    expandedCells = Array(repeating: CellOperation.collapsed, count: items.count)
    self.addSubview(tableView)
    self.addSubview(titleLabel)
    addConstraintsForTableViewAndTitleLabel()
