fixed an error if db empty