small contextindex refactoring