             elementFrame.origin.y += elementFrame.size.height
             elementFrame.size.height = self.frame.size.height - elementFrame.size.height
             
-            self.collectionView.frame = CGRect(x:0.0, y:80.0, width: self.frame.size.width, height:self.frame.size.height - 80.0)
-            
-            let layout = self.collectionView.collectionViewLayout as! KDCalendarFlowLayout
-            
-            self.collectionView.collectionViewLayout = layout
+            self.calendarView.frame = CGRect(x:0.0, y:80.0, width: self.frame.size.width, height:self.frame.size.height - 80.0)
+            
+            let layout = self.calendarView.collectionViewLayout as! KDCalendarFlowLayout
+            
+            self.calendarView.collectionViewLayout = layout
             
         }
     }

    
    func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        
        let cvbounds = self.collectionView.bounds
        
        var page : Int = Int(floor(self.collectionView.contentOffset.x / cvbounds.size.width))

        page = page > 0 ? page : 0
        
        
        self.collectionView.collectionViewLayout.layoutAttributesForElementsInRect(cvbounds)
        
        if let monthName = formatter.monthSymbols[page % 12] as? String {
            

        self.clipsToBounds = true
        
        // Register Class
        self.calendarView.registerClass(KDCalendarDayCell.self, forCellWithReuseIdentifier: cellReuseIdentifier)
        
        
        self.addSubview(self.headerView)
        self.addSubview(self.calendarView)
    }
    
    
