Fixing bug when the db is empty