     }
     
     mutating func add(chapter: Chapter) throws {
+        if chapters.map({$0.name}).index(of: chapter.name) != nil {
+            throw NSError.error(description: "Already page has been added.")
+        }
         chapters.append(chapter)
         do {
             try writeManifest()

    }
    
    mutating func add(page: Page) throws {
        pages.append(page)
        do {
            try writeManifest()

        contentVersion = aContentVersion
        imageReference = anImageReference
        deploymentTarget = aDeploymentTarget
        chapters = arrayChapters.map({ (name) -> Chapter in
            let title = name.replacingOccurrences(of: ".playgroundchapter", with: "")
            print("\(name) => \(title)")
            return Chapter(name: title)
        })
    }
    
    func getChapter(name: String) throws -> Chapter {
