                 self.saveImage(image, fileName: fileName, type: "png", directoryPath: pathForWriting)
                 downloadedTilesConst += 1
                 
-                //                print("downloadedTiles: \(downloadedTilesConst)")
+                print("downloadedTiles: \(downloadedTilesConst)")
                 
                 guard error == nil && temporaryURL != nil else {
                     print(error)

                            
                            self.stopDownloading()
                            
                            let alertController = UIAlertController (title: "Thank you!", message: "Maps will be switched automatically once you will be offline", preferredStyle: .alert)
                            
                            let action = UIAlertAction(title:"Ok", style: .default) { (_) -> Void in

    
    // - All about tiles downloading -
    
    fileprivate func startBackgroundTask() {
        // Start background task
        if self.backgrountTask == nil {
            self.backgrountTask = UIApplication.shared.beginBackgroundTask {
                guard let identifier = self.backgrountTask else { return }
                UIApplication.shared.endBackgroundTask(identifier)
                self.backgrountTask = nil
            }
        }
    }
    
    fileprivate func stopBackgroundTask() {
        
        // End background task
        if let identifier = self.backgrountTask {
            UIApplication.shared.endBackgroundTask(identifier)
            self.backgrountTask = nil
        }
    }
    
    
    fileprivate func transformWorldCoordinateToTilePathForZoom(_ zoom: Int, lon: Double, lat : Double) -> (x: Int, y: Int) {
        
        let midtileX = floor((lon + 180.0) / 360.0 * pow(2.0, Double(zoom)))
