Fixed a bug with empty db