         daysButton.removeAll()
         
         self.daysLabel.forEach { currentDay in
-            let button = UIButton(frame: CGRectMake(CGFloat(position) * itemWidth, 0, itemWidth, itemHeight))
+            let button = UIButton(frame: CGRect(x: CGFloat(position) * itemWidth, y:0, width: itemWidth, height: itemHeight))
             let layer = CALayer()
             let tuple = CHButton(button, false, layer)
             
-            configureButton(tuple, title: currentDay, position: position)
-            configureLayer(tuple)
+            configureButton(tuple: tuple, title: currentDay, position: position)
+            configureLayer(tuple: tuple)
             daysButton.append(tuple)
             
             if position == defaultSelectedDay {
-                selectDay(button)
+                selectDay(sender: button)
             }
             
             position += 1

    }
    
    private func configureButton(tuple : CHButton, title : String, position : Int) {
        tuple.button.setTitle(title, forState: UIControlState.Normal)
        tuple.button.layer.cornerRadius = self.frame.height/2
        if self.defaultSelectedDay == position {
            tuple.button.setTitleColor(selectedTitleColor, forState: .Normal)
        } else {
            tuple.button.setTitleColor(titleColor, forState: .Normal)
        }
        tuple.button.addTarget(self, action: #selector(CHDayPicker.selectDay(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        tuple.button.tag = position
        self.addSubview(tuple.button)
    }
    
    private func configureLayer(tuple : CHButton) {
        let minSize = min(tuple.button.frame.size.width, tuple.button.frame.size.height)
        tuple.selectedLayer.frame = CGRectMake(tuple.button.frame.size.width/2 - minSize/2, tuple.button.frame.size.height/2 - minSize/2 , minSize, minSize)
        tuple.selectedLayer.backgroundColor = UIColor.clearColor().CGColor
        tuple.selectedLayer.cornerRadius = minSize/2
        tuple.button.layer.addSublayer(tuple.selectedLayer)
    }

        
        switch daysButton[sender.tag].selected {
        case true:
            selectDayAtPosition(position: sender.tag)
        case false :
            deselectDayAtPosition(position: sender.tag)
        }
        self.delegate?.didSelectDay(position: sender.tag, label: daysLabel[sender.tag], selected: daysButton[sender.tag].selected)
    }
    
    public func selectDayAtPosition(position : Int) {
        if self.daysButton.count > position && position >= 0{
            self.daysButton[position].selected = true
            self.daysButton[position].button.setTitleColor(selectedTitleColor, for: .normal)
            self.daysButton[position].selectedLayer.backgroundColor = selectedBackgroundColor.cgColor
        }
    }
    
    public func deselectDayAtPosition(position : Int) {
        if self.daysButton.count >= position {
            self.daysButton[position].selected = false
            self.daysButton[position].button.setTitleColor(titleColor, for: .normal)
            self.daysButton[position].selectedLayer.backgroundColor = UIColor.clear.cgColor
        }
    }
    
    private func setActive(tuple : CHButton) {
        tuple.button.setTitleColor(selectedTitleColor, for: .normal)
        tuple.selectedLayer.backgroundColor = selectedBackgroundColor.cgColor
        
    }
    
    private func setInActive(tuple : CHButton) {
        tuple.button.setTitleColor(titleColor, for: .normal)
        tuple.selectedLayer.backgroundColor = UIColor.clear.cgColor
    }
}

