refactored indexer.py and document.py