add handle for empty database case