             
             // Insert the Default profile into the Profiles table if it doesn't exist
             
-            if (try db.scalar(profiles.table.filter(profiles.profileId == 0).count)) == 0 {
+            if (try db.scalar(profiles.table.filter(profiles.name == "Default").count)) == 0 {
                 let insert = profiles.table.insert(profiles.name <- "Default")
                 _ = try? db.run(insert)
             }

            let db_path = dbObjects().db_path
            let db = try Connection("\(db_path)/db.sqlite3")
            
            // Database object references
            let ngrams = dbObjects.Ngrams()
            let profiles = dbObjects.Profiles()

class dbObjects {
    
    let db_path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
    
    
    struct Ngrams {
        let table = Table("Ngrams")
