 // MARK: - Hard code
 
 extension MergeVideosViewController {
-    private func addTienScenceAtTime(startTime: CMTime,
+    private func addVideoItemScenceAtTime(startTime: CMTime,
                                      parentLayer: CALayer,
                                      composition: AVMutableComposition,
+                                     videoAsset: AVAsset,
+                                     title: String,
                                      videoItemSize: CGSize) -> (AVMutableVideoCompositionInstruction, endTime: CMTime) {
-        var atTime = startTime
-        let tienAsset = assets[0]
+        let randomSide = Int(arc4random()) % 2 == 0
+        let startPoint = randomSide ? CGPoint(x: -parentLayer.bounds.width/2, y: parentLayer.bounds.height/2) : CGPoint(x: parentLayer.bounds.width*3/2, y: parentLayer.bounds.height/2)
+        let endPoint = randomSide ? CGPoint(x: (parentLayer.bounds.width/2 - videoItemSize.width/2)/2 - 20,
+                                            y: startPoint.y) : CGPoint(x: (parentLayer.bounds.width/2 + videoItemSize.width/2)/2 + 20, y: startPoint.y)
+        
+        let atTime = startTime
         let backgroundColor = UIColor(red: 102/255, green: 89/255, blue: 255/255, alpha: 1).CGColor
         
         let tienTitleTextLayer = CATextLayer()
-        tienTitleTextLayer.string = "Tien"
+        tienTitleTextLayer.string = title
         tienTitleTextLayer.font = font1
         tienTitleTextLayer.fontSize = 40
         tienTitleTextLayer.foregroundColor = UIColor(red: 232/255, green: 212/255, blue: 65/255, alpha: 1).CGColor
         tienTitleTextLayer.alignmentMode = kCAAlignmentRight
         tienTitleTextLayer.frame = CGRect(origin: .zero,
                                           size: CGSize(width: parentLayer.bounds.width/2 - videoItemSize.width/2, height: 50))
-        tienTitleTextLayer.position = CGPoint(x: -parentLayer.bounds.width/2, y: parentLayer.bounds.height/2)
+        tienTitleTextLayer.position = startPoint
         tienTitleTextLayer.opacity = 0.0
         parentLayer.addSublayer(tienTitleTextLayer)
         

                  duration: 0.35,
                  beginTime: atTime.seconds + 1.0,
                  fromPoint: tienTitleTextLayer.position,
                  toPoint: CGPoint(x: (parentLayer.bounds.width/2 - videoItemSize.width/2)/2,
                    y: tienTitleTextLayer.position.y),
                  damping: true)
        
        moveLayer(tienTitleTextLayer,
                  duration: 0.35,
                  beginTime: atTime.seconds - 1.0 + tienAsset.duration.seconds,
                  fromPoint: tienTitleTextLayer.position,
                  toPoint: CGPoint(x: -parentLayer.bounds.width/2,
                    y: tienTitleTextLayer.position.y),
                  damping: true)
        
        hideLayer(tienTitleTextLayer,
                  hidden: true,
                  duration: 0,
                  beginTime: atTime.seconds + tienAsset.duration.seconds)
        
        //// Instruction
        let tienTrack = composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
        try! tienTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, tienAsset.duration), ofTrack: tienAsset.tracksWithMediaType(AVMediaTypeVideo)[0], atTime: atTime)
        let tienLayerInstruction = videoCompositionInstructionForTrack(tienTrack,
                                                                       asset: tienAsset,
                                                                       fixRotate: true,
                                                                       frame: CGRect(origin: CGPoint(x: ExportedVideoSize.width/2 - videoItemSize.width/2, y: 0),
                                                                        size: videoItemSize))
        
        let tienInstruction = AVMutableVideoCompositionInstruction()
        tienInstruction.timeRange = CMTimeRangeMake(atTime, tienAsset.duration)
        tienInstruction.backgroundColor = backgroundColor
        tienInstruction.layerInstructions = [tienLayerInstruction]
        
        
        let endTime = CMTimeAdd(startTime, tienAsset.duration)
        return (tienInstruction, endTime)
        
    }

        ////////////////////////////////////////////////
        let renderSize = ExportedVideoSize
        let mainComposition = AVMutableVideoComposition(propertiesOfAsset: mixComposition)
        mainComposition.instructions = instructions
        mainComposition.frameDuration = CMTimeMake(1, 30)
        mainComposition.renderSize = renderSize
        mainComposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
        ////////////////////////////////////////////////
        ////////////////////////////////////////////////
