fix empty database bug