add logging. store documents retrieved in database.