 		}
 	}
 	
+	override open func awakeFromNib() {
+		super.awakeFromNib()
+		if expyDelegate == nil {
+			//Set UITableViewDelegate even if ExpyTableViewDelegate is nil. Because we are getting callbacks here in didSelectRowAtIndexPath UITableViewDelegate method.
+			super.delegate = self
+		}
+	}
+	
 	open func getActionType(forSection section: Int) -> ExpyActionType {
 		let sectionIsVisible = visibleSections[section] ?? false
 		return sectionIsVisible ? .expand : .collapse
-	}
-	
-	open override func awakeFromNib() {
-		super.awakeFromNib()
-		
-		//Set UITableViewDelegate even if ExpyTableViewDelegate is nil. Because we are getting callbacks here in didSelectRowAtIndexPath UITableViewDelegate method.
-		if expyDelegate == nil {
-			super.delegate = self
-		}
 	}
 }
 

extension ExpyTableView: UITableViewDelegate {
	
	open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
		let sectionExistsInExpandableSections = expandableSections[indexPath.section] ?? false
		let sectionExistsInVisibleSections = visibleSections[indexPath.section] ?? false
		
		expyDelegate?.tableView?(tableView, didSelectRowAt: indexPath)
		
		guard sectionExistsInExpandableSections && (indexPath.row == 0) else { return }
		
		if sectionExistsInVisibleSections {
			collapse(indexPath.section, inTableView: self)
		}else {
			expand(indexPath.section, inTableView: self)
		}
	}
}

	fileprivate weak var expyDataSource: ExpyTableViewDataSource?
	fileprivate weak var expyDelegate: ExpyTableViewDelegate?
	
	public fileprivate(set) var expandableSections: [Int: Bool] = [:]
	public fileprivate(set) var visibleSections: [Int: Bool] = [:]
	
	open var expandingAnimation: UITableViewRowAnimation = .fade
	open var collapsingAnimation: UITableViewRowAnimation = .fade
