first working indexer, needs serious refactoring