 
     func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) {
         print(code)
-        controller.reset()
+//        controller.reset()
+
+        controller.dismiss(animated: true, completion: nil)
+        
+        self.alertForAddingBook(ISBN: code)
+
+        
     }
     
-    func alertForCreateAccount() {
+    func barcodeScannerDidDismiss(_ controller: BarcodeScannerController) {
+        controller.dismiss(animated: true, completion: nil)
+    }
+    
+    func alertForAddingBook(ISBN: String) {
         
         var booknameCreated: String = ""
-        let bookISBNCreated: String = ""
+        let bookISBNCreated: String = ISBN
         let bookImageCreated: String = ""
         
         
-        let alert = UIAlertController(title: "Add new book", message: "", preferredStyle: UIAlertControllerStyle.alert)
+        let alert = UIAlertController(title: "Add new book", message: bookISBNCreated, preferredStyle: UIAlertControllerStyle.alert)
         alert.addAction(UIAlertAction(title: "Add", style: UIAlertActionStyle.default, handler: { action in
             
             let bookNameTextField = alert.textFields![0] as UITextField

let bookDict2: [String:Any] = [ "name" : "booktitle2" , "ISBNcode" : "23456789", "pic" : "", "notesCount": 12 ]
var allBookArray: [Any] = [bookDict1, bookDict2]

class BooklistViewController: UITableViewController, BarcodeScannerCodeDelegate {

    @IBAction func addBookButton(_ sender: UIButton) {
    
        //Camera
        //Barcode
        
        
        
        let controller = BarcodeScannerController()
        controller.codeDelegate = self
        
        navigationController?.pushViewController(controller, animated: true)
        
        alertForCreateAccount()
        
    }


                let newBookDict: [String:Any] = [
                
                    "name" : booknameCreated,
                    "ISBNcode" : bookISBNCreated,
                    "pic" : bookImageCreated,
                    "notesCount" : 0
                ]
                
                allBookArray.append(newBookDict)
                print(allBookArray)
                self.tableView.reloadData()
                
            } else {
                
