                 if !result.isEmpty {
                     print("Result: \(result), total frame calcuated: \(calcuatedFramesCount)")
                     found = true
-                    DispatchQueue.main.async {
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "com.hanguang.app.puzzle.PuzzleFinishedNotification"),
-                                                        object: nil, userInfo: ["resutls": result])
-                    }
+                    completion(result)
                 }
                 
                 currentFramesQueue = nextFramesQueue

    }
}

private struct PuzzleFrame: Hashable {
    var hashValue: Int {
        let data: Data = Data(bytes: frame.map { $0.rawValue })
        return data.hashValue
    }
    
    let previousStep: Int8
    let currentStep: Int8
    let frame: [Tile]
    let steps: [Int8]
    
    init(previousStep: Int8, currentStep: Int8, frame: [Tile], steps: [Int8]) {
        self.previousStep = previousStep;
        self.currentStep = currentStep
        self.frame = frame
        self.steps = steps
    }
}


//            }
            self.puzzle.calcuateTheShortestWay({ (result) in
                DispatchQueue.main.async {
                    let stringResult: String = result.reduce("", { (result, value) -> String in
                        switch value {
                        case -4:
                            return result + "U"
                        case 4:
                            return result + "D"
                        case -1:
                            return result + "L"
                        case 1:
                            return result + "R"
                        default:
                            return ""
                        }
                    })
                    
                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "com.hanguang.app.puzzle.PuzzleFinishedNotification"),
                                                    object: nil, userInfo: ["resutls": [stringResult as NSString]])
                }
            })
        }
