added error check when db is empty.