Fix bug getting the next document from a server