simplified the if-else clause
simplified the if-else clause
added boolean field "indexed" to document to mark indexing status.