         let image = UIImage(CGImage: thumbnail)
         let imageData = UIImageJPEGRepresentation(image, 0.8)
         
-        let cacheDirPath: NSString = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0] as! NSString
+        let cacheDirPath: NSString = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0] as? NSString
         let filePath = cacheDirPath.stringByAppendingPathComponent("\(id).jpeg")
         
-        if imageData.writeToFile(filePath, atomically: true){
+        if imageData?.writeToFile(filePath, atomically: true){
             return filePath
         } else {
-            println("error occured: Cannot save thumbnail image")
+            print("error occured: Cannot save thumbnail image")
             return ""
         }
     }

    
    // TODO: Add music and playlist and audio
    private func getFilter(mediaTypes: [String]) -> ALAssetsFilter?{
        if contains(mediaTypes, "image"){
            if contains(mediaTypes, "video"){
                return ALAssetsFilter.allAssets()
            } else {
                return ALAssetsFilter.allPhotos()
            }
        } else if contains(mediaTypes, "video"){
            return ALAssetsFilter.allVideos()
        }
        return nil

        dispatch_async(dispatch_get_global_queue(priority, 0)){
            self.result = []
            self.command = command
            let temp = command.arguments[0] as! [String: AnyObject]
            self.option = self.initailizeOption(temp)
            self.loadMedia(self.option)
        }
