fix error when db is empty