fixing empty database bug