Change checkDataBase function

New implementation of checkDataBase function since this generated a lot
of exceptions.