Updated the db class so that it wouldn't crash