Bug fix to documentExists