     }
     
     public func attributesForCollectionView(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
-        let attributes = super.layoutAttributesForItem(at: indexPath)!
+        guard let attributes = super.layoutAttributesForItem(at: indexPath) else {
+            return nil
+        }
+        
         let item = CGFloat(indexPath.item)
         let width = collectionView.bounds.size.width
         let height = collectionView.bounds.size.height
         let cellSize = configuration.cellSize
         let cellHeight = cellSize.height
-        var visibleCount = CGFloat(min(configuration.visibleCount, cellCount))
-        visibleCount = max(1, visibleCount)
+        var visibleCount = configuration.visibleCount <= 0 ? CGFloat(cellCount) : CGFloat(min(configuration.visibleCount, cellCount))
         var centerX: CGFloat = 0.0
         var centerY: CGFloat = 0.0
         

        var itemOffset: CGFloat
        
        if configuration.reversed {
            itemOffset = topItemIndex-item
            attributes.zIndex = indexPath.item
        } else {
            itemOffset =  item-topItemIndex
            attributes.zIndex = -indexPath.item
        }
        


open class CPTimeMachineLayoutConfiguration: CPLayoutConfiguration {
    
    public var visibleCount = 0
    public var minCellSize = CGSize(width: 50, height: 50)
    public var scaleFactor: CGFloat = 0.5//(0, 1)
    public var spacingX: CGFloat = 20
